mirror of
https://github.com/taglib/taglib.git
synced 2025-07-23 07:24:30 -04:00
Merge branch 'master' into taglib2
Conflicts: taglib/mp4/mp4tag.cpp taglib/mp4/mp4tag.h taglib/toolkit/tfile.cpp
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
#include <tag.h>
|
||||
#include <tstringlist.h>
|
||||
#include <tbytevectorlist.h>
|
||||
#include <tpropertymap.h>
|
||||
#include <asffile.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include "utils.h"
|
||||
@ -13,7 +14,7 @@ using namespace TagLib;
|
||||
class TestASF : public CppUnit::TestFixture
|
||||
{
|
||||
CPPUNIT_TEST_SUITE(TestASF);
|
||||
CPPUNIT_TEST(testProperties);
|
||||
CPPUNIT_TEST(testAudioProperties);
|
||||
CPPUNIT_TEST(testRead);
|
||||
CPPUNIT_TEST(testSaveMultipleValues);
|
||||
CPPUNIT_TEST(testSaveStream);
|
||||
@ -22,11 +23,12 @@ class TestASF : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testSaveLargeValue);
|
||||
CPPUNIT_TEST(testSavePicture);
|
||||
CPPUNIT_TEST(testSaveMultiplePictures);
|
||||
CPPUNIT_TEST(testProperties);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
|
||||
void testProperties()
|
||||
void testAudioProperties()
|
||||
{
|
||||
ASF::File f(TEST_FILE_PATH_C("silence-1.wma"));
|
||||
CPPUNIT_ASSERT_EQUAL(4, f.audioProperties()->length());
|
||||
@ -215,6 +217,39 @@ public:
|
||||
delete f;
|
||||
}
|
||||
|
||||
void testProperties()
|
||||
{
|
||||
ASF::File f(TEST_FILE_PATH_C("silence-1.wma"));
|
||||
|
||||
PropertyMap tags = f.properties();
|
||||
|
||||
tags["TRACKNUMBER"] = StringList("2");
|
||||
tags["DISCNUMBER"] = StringList("3");
|
||||
tags["BPM"] = StringList("123");
|
||||
tags["ARTIST"] = StringList("Foo Bar");
|
||||
f.setProperties(tags);
|
||||
|
||||
tags = f.properties();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(String("Foo Bar"), f.tag()->artist());
|
||||
CPPUNIT_ASSERT_EQUAL(StringList("Foo Bar"), tags["ARTIST"]);
|
||||
|
||||
CPPUNIT_ASSERT(f.tag()->attributeListMap().contains("WM/BeatsPerMinute"));
|
||||
CPPUNIT_ASSERT_EQUAL(1u, f.tag()->attributeListMap()["WM/BeatsPerMinute"].size());
|
||||
CPPUNIT_ASSERT_EQUAL(String("123"), f.tag()->attributeListMap()["WM/BeatsPerMinute"].front().toString());
|
||||
CPPUNIT_ASSERT_EQUAL(StringList("123"), tags["BPM"]);
|
||||
|
||||
CPPUNIT_ASSERT(f.tag()->attributeListMap().contains("WM/TrackNumber"));
|
||||
CPPUNIT_ASSERT_EQUAL(1u, f.tag()->attributeListMap()["WM/TrackNumber"].size());
|
||||
CPPUNIT_ASSERT_EQUAL(String("2"), f.tag()->attributeListMap()["WM/TrackNumber"].front().toString());
|
||||
CPPUNIT_ASSERT_EQUAL(StringList("2"), tags["TRACKNUMBER"]);
|
||||
|
||||
CPPUNIT_ASSERT(f.tag()->attributeListMap().contains("WM/PartOfSet"));
|
||||
CPPUNIT_ASSERT_EQUAL(1u, f.tag()->attributeListMap()["WM/PartOfSet"].size());
|
||||
CPPUNIT_ASSERT_EQUAL(String("3"), f.tag()->attributeListMap()["WM/PartOfSet"].front().toString());
|
||||
CPPUNIT_ASSERT_EQUAL(StringList("3"), tags["DISCNUMBER"]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestASF);
|
||||
|
@ -624,7 +624,7 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(String("A COMMENT"), dict["COMMENT"].front());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1u, dict.unsupportedData().size());
|
||||
CPPUNIT_ASSERT_EQUAL(String("UFID"), dict.unsupportedData().front());
|
||||
CPPUNIT_ASSERT_EQUAL(String("UFID/supermihi@web.de"), dict.unsupportedData().front());
|
||||
}
|
||||
|
||||
void testPropertyInterface2()
|
||||
@ -657,11 +657,23 @@ public:
|
||||
frame5->setText(tmclData);
|
||||
tag.addFrame(frame5);
|
||||
|
||||
ID3v2::UniqueFileIdentifierFrame *frame6 = new ID3v2::UniqueFileIdentifierFrame("http://musicbrainz.org", "152454b9-19ba-49f3-9fc9-8fc26545cf41");
|
||||
tag.addFrame(frame6);
|
||||
|
||||
ID3v2::UniqueFileIdentifierFrame *frame7 = new ID3v2::UniqueFileIdentifierFrame("http://example.com", "123");
|
||||
tag.addFrame(frame7);
|
||||
|
||||
ID3v2::UserTextIdentificationFrame *frame8 = new ID3v2::UserTextIdentificationFrame();
|
||||
frame8->setDescription("MusicBrainz Album Id");
|
||||
frame8->setText("95c454a5-d7e0-4d8f-9900-db04aca98ab3");
|
||||
tag.addFrame(frame8);
|
||||
|
||||
PropertyMap properties = tag.properties();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(2u, properties.unsupportedData().size());
|
||||
CPPUNIT_ASSERT_EQUAL(3u, properties.unsupportedData().size());
|
||||
CPPUNIT_ASSERT(properties.unsupportedData().contains("TIPL"));
|
||||
CPPUNIT_ASSERT(properties.unsupportedData().contains("APIC"));
|
||||
CPPUNIT_ASSERT(properties.unsupportedData().contains("UFID/http://example.com"));
|
||||
|
||||
CPPUNIT_ASSERT(properties.contains("PERFORMER:VIOLIN"));
|
||||
CPPUNIT_ASSERT(properties.contains("PERFORMER:PIANO"));
|
||||
@ -671,9 +683,17 @@ public:
|
||||
CPPUNIT_ASSERT(properties.contains("LYRICS"));
|
||||
CPPUNIT_ASSERT(properties.contains("LYRICS:TEST"));
|
||||
|
||||
CPPUNIT_ASSERT(properties.contains("MUSICBRAINZ_TRACKID"));
|
||||
CPPUNIT_ASSERT_EQUAL(String("152454b9-19ba-49f3-9fc9-8fc26545cf41"), properties["MUSICBRAINZ_TRACKID"].front());
|
||||
|
||||
CPPUNIT_ASSERT(properties.contains("MUSICBRAINZ_ALBUMID"));
|
||||
CPPUNIT_ASSERT_EQUAL(String("95c454a5-d7e0-4d8f-9900-db04aca98ab3"), properties["MUSICBRAINZ_ALBUMID"].front());
|
||||
|
||||
tag.removeUnsupportedProperties(properties.unsupportedData());
|
||||
CPPUNIT_ASSERT(tag.frameList("APIC").isEmpty());
|
||||
CPPUNIT_ASSERT(tag.frameList("TIPL").isEmpty());
|
||||
CPPUNIT_ASSERT_EQUAL((ID3v2::UniqueFileIdentifierFrame *)0, ID3v2::UniqueFileIdentifierFrame::findByOwner(&tag, "http://example.com"));
|
||||
CPPUNIT_ASSERT_EQUAL(frame6, ID3v2::UniqueFileIdentifierFrame::findByOwner(&tag, "http://musicbrainz.org"));
|
||||
}
|
||||
|
||||
void testDeleteFrame()
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <tag.h>
|
||||
#include <mp4tag.h>
|
||||
#include <tbytevectorlist.h>
|
||||
#include <tpropertymap.h>
|
||||
#include <mp4atom.h>
|
||||
#include <mp4file.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
@ -25,6 +26,7 @@ class TestMP4 : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testCovrRead);
|
||||
CPPUNIT_TEST(testCovrWrite);
|
||||
CPPUNIT_TEST(testCovrRead2);
|
||||
CPPUNIT_TEST(testProperties);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -224,6 +226,55 @@ public:
|
||||
delete f;
|
||||
}
|
||||
|
||||
void testProperties()
|
||||
{
|
||||
MP4::File f(TEST_FILE_PATH_C("has-tags.m4a"));
|
||||
|
||||
PropertyMap tags = f.properties();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(StringList("Test Artist"), tags["ARTIST"]);
|
||||
|
||||
tags["TRACKNUMBER"] = StringList("2/4");
|
||||
tags["DISCNUMBER"] = StringList("3/5");
|
||||
tags["BPM"] = StringList("123");
|
||||
tags["ARTIST"] = StringList("Foo Bar");
|
||||
tags["COMPILATION"] = StringList("1");
|
||||
f.setProperties(tags);
|
||||
|
||||
tags = f.properties();
|
||||
|
||||
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("trkn"));
|
||||
CPPUNIT_ASSERT_EQUAL(2, f.tag()->itemListMap()["trkn"].toIntPair().first);
|
||||
CPPUNIT_ASSERT_EQUAL(4, f.tag()->itemListMap()["trkn"].toIntPair().second);
|
||||
CPPUNIT_ASSERT_EQUAL(StringList("2/4"), tags["TRACKNUMBER"]);
|
||||
|
||||
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("disk"));
|
||||
CPPUNIT_ASSERT_EQUAL(3, f.tag()->itemListMap()["disk"].toIntPair().first);
|
||||
CPPUNIT_ASSERT_EQUAL(5, f.tag()->itemListMap()["disk"].toIntPair().second);
|
||||
CPPUNIT_ASSERT_EQUAL(StringList("3/5"), tags["DISCNUMBER"]);
|
||||
|
||||
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("tmpo"));
|
||||
CPPUNIT_ASSERT_EQUAL(123, f.tag()->itemListMap()["tmpo"].toInt());
|
||||
CPPUNIT_ASSERT_EQUAL(StringList("123"), tags["BPM"]);
|
||||
|
||||
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("\251ART"));
|
||||
CPPUNIT_ASSERT_EQUAL(StringList("Foo Bar"), f.tag()->itemListMap()["\251ART"].toStringList());
|
||||
CPPUNIT_ASSERT_EQUAL(StringList("Foo Bar"), tags["ARTIST"]);
|
||||
|
||||
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("cpil"));
|
||||
CPPUNIT_ASSERT_EQUAL(true, f.tag()->itemListMap()["cpil"].toBool());
|
||||
CPPUNIT_ASSERT_EQUAL(StringList("1"), tags["COMPILATION"]);
|
||||
|
||||
tags["COMPILATION"] = StringList("0");
|
||||
f.setProperties(tags);
|
||||
|
||||
tags = f.properties();
|
||||
|
||||
CPPUNIT_ASSERT(f.tag()->itemListMap().contains("cpil"));
|
||||
CPPUNIT_ASSERT_EQUAL(false, f.tag()->itemListMap()["cpil"].toBool());
|
||||
CPPUNIT_ASSERT_EQUAL(StringList("0"), tags["COMPILATION"]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestMP4);
|
||||
|
Reference in New Issue
Block a user