mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Added another test for ID3v2 PropertyMap interface; fixed various bugs
This commit is contained in:
parent
495a028da3
commit
d28cc83fb4
@ -260,7 +260,8 @@ PropertyMap TextIdentificationFrame::makeTIPLProperties() const
|
||||
map.unsupportedData().append(frameID());
|
||||
return map;
|
||||
}
|
||||
for(StringList::ConstIterator it = fieldList().begin(); it != fieldList().end(); ++it) {
|
||||
StringList l = fieldList();
|
||||
for(StringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
|
||||
bool found = false;
|
||||
for(uint i = 0; i < involvedPeopleSize; ++i)
|
||||
if(*it == involvedPeople[i][0]) {
|
||||
@ -286,7 +287,8 @@ PropertyMap TextIdentificationFrame::makeTMCLProperties() const
|
||||
map.unsupportedData().append(frameID());
|
||||
return map;
|
||||
}
|
||||
for(StringList::ConstIterator it = fieldList().begin(); it != fieldList().end(); ++it) {
|
||||
StringList l = fieldList();
|
||||
for(StringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
|
||||
String instrument = PropertyMap::prepareKey(*it);
|
||||
if(instrument.isNull()) {
|
||||
// instrument is not a valid key -> frame unsupported
|
||||
|
@ -114,11 +114,11 @@ void UnsynchronizedLyricsFrame::setTextEncoding(String::Type encoding)
|
||||
|
||||
PropertyMap UnsynchronizedLyricsFrame::asProperties() const
|
||||
{
|
||||
String key = PropertyMap::prepareKey(description());
|
||||
PropertyMap map;
|
||||
if(key.isEmpty())
|
||||
key = "LYRICS";
|
||||
if(key.isNull())
|
||||
String key = PropertyMap::prepareKey(description());
|
||||
if(key.isEmpty() || key.upper() == "LYRICS")
|
||||
map.insert("LYRICS", text());
|
||||
else if(key.isNull())
|
||||
map.unsupportedData().append(L"USLT/" + description());
|
||||
else
|
||||
map.insert("LYRICS:" + key, text());
|
||||
|
@ -339,6 +339,7 @@ PropertyMap ID3v2::Tag::properties() const
|
||||
PropertyMap properties;
|
||||
for(FrameList::ConstIterator it = frameList().begin(); it != frameList().end(); ++it) {
|
||||
PropertyMap props = (*it)->asProperties();
|
||||
debug("read properties:\n" + props.toString());
|
||||
properties.merge(props);
|
||||
}
|
||||
return properties;
|
||||
|
@ -166,6 +166,8 @@ String PropertyMap::toString() const
|
||||
String ret = "";
|
||||
for(ConstIterator it = begin(); it != end(); ++it)
|
||||
ret += it->first+"="+it->second.toString(", ") + "\n";
|
||||
if(!unsupported.isEmpty())
|
||||
ret += "Unsupported Data: " + unsupported.toString(", ") + "\n";
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <uniquefileidentifierframe.h>
|
||||
#include <textidentificationframe.h>
|
||||
#include <attachedpictureframe.h>
|
||||
#include <unsynchronizedlyricsframe.h>
|
||||
#include <generalencapsulatedobjectframe.h>
|
||||
#include <relativevolumeframe.h>
|
||||
#include <popularimeterframe.h>
|
||||
@ -68,7 +69,8 @@ class TestID3v2 : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testDowngradeTo23);
|
||||
// CPPUNIT_TEST(testUpdateFullDate22); TODO TYE+TDA should be upgraded to TDRC together
|
||||
CPPUNIT_TEST(testCompressedFrameWithBrokenLength);
|
||||
CPPUNIT_TEST(testDictInterface);
|
||||
CPPUNIT_TEST(testPropertyInterface);
|
||||
CPPUNIT_TEST(testPropertyInterface2);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -549,7 +551,7 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::uint(86414), frame->picture().size());
|
||||
}
|
||||
|
||||
void testDictInterface()
|
||||
void testPropertyInterface()
|
||||
{
|
||||
ScopedFileCopy copy("rare_frames", ".mp3");
|
||||
string newname = copy.fileName();
|
||||
@ -572,6 +574,55 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(String("UFID"), dict.unsupportedData().front());
|
||||
}
|
||||
|
||||
void testPropertyInterface2()
|
||||
{
|
||||
ID3v2::Tag tag;
|
||||
ID3v2::UnsynchronizedLyricsFrame *frame1 = new ID3v2::UnsynchronizedLyricsFrame();
|
||||
frame1->setDescription("test");
|
||||
frame1->setText("la-la-la test");
|
||||
tag.addFrame(frame1);
|
||||
|
||||
ID3v2::UnsynchronizedLyricsFrame *frame2 = new ID3v2::UnsynchronizedLyricsFrame();
|
||||
frame2->setDescription("");
|
||||
frame2->setText("la-la-la nodescription");
|
||||
tag.addFrame(frame2);
|
||||
|
||||
ID3v2::AttachedPictureFrame *frame3 = new ID3v2::AttachedPictureFrame();
|
||||
frame3->setDescription("test picture");
|
||||
tag.addFrame(frame3);
|
||||
|
||||
ID3v2::TextIdentificationFrame *frame4 = new ID3v2::TextIdentificationFrame("TIPL");
|
||||
frame4->setText("single value is invalid for TIPL");
|
||||
tag.addFrame(frame4);
|
||||
|
||||
ID3v2::TextIdentificationFrame *frame5 = new ID3v2::TextIdentificationFrame("TMCL");
|
||||
StringList tmclData;
|
||||
tmclData.append("VIOLIN");
|
||||
tmclData.append("a violinist");
|
||||
tmclData.append("PIANO");
|
||||
tmclData.append("a pianist");
|
||||
frame5->setText(tmclData);
|
||||
tag.addFrame(frame5);
|
||||
|
||||
PropertyMap properties = tag.properties();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2u, properties.unsupportedData().size());
|
||||
CPPUNIT_ASSERT(properties.unsupportedData().contains("TIPL"));
|
||||
CPPUNIT_ASSERT(properties.unsupportedData().contains("APIC"));
|
||||
|
||||
CPPUNIT_ASSERT(properties.contains("PERFORMER:VIOLIN"));
|
||||
CPPUNIT_ASSERT(properties.contains("PERFORMER:PIANO"));
|
||||
CPPUNIT_ASSERT_EQUAL(String("a violinist"), properties["PERFORMER:VIOLIN"].front());
|
||||
CPPUNIT_ASSERT_EQUAL(String("a pianist"), properties["PERFORMER:PIANO"].front());
|
||||
|
||||
CPPUNIT_ASSERT(properties.contains("LYRICS"));
|
||||
CPPUNIT_ASSERT(properties.contains("LYRICS:TEST"));
|
||||
|
||||
tag.removeUnsupportedProperties(properties.unsupportedData());
|
||||
CPPUNIT_ASSERT(tag.frameList("APIC").isEmpty());
|
||||
CPPUNIT_ASSERT(tag.frameList("TIPL").isEmpty());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v2);
|
||||
|
Loading…
Reference in New Issue
Block a user