12void OverallTests::checkFlacTestfile1()
14 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Flac, m_fileInfo.
containerFormat());
15 const auto tracks = m_fileInfo.
tracks();
16 CPPUNIT_ASSERT_EQUAL(1_st, tracks.size());
17 for (
const auto &track : tracks) {
18 CPPUNIT_ASSERT_EQUAL(MediaType::Audio, track->mediaType());
19 CPPUNIT_ASSERT_EQUAL(GeneralMediaFormat::Flac, track->format().general);
20 CPPUNIT_ASSERT_EQUAL(
static_cast<std::uint16_t
>(2), track->channelCount());
21 CPPUNIT_ASSERT_EQUAL(44100u, track->samplingFrequency());
22 CPPUNIT_ASSERT_EQUAL(
static_cast<std::uint16_t
>(16), track->bitsPerSample());
23 CPPUNIT_ASSERT_EQUAL(4, track->duration().minutes());
25 const auto tags = m_fileInfo.
tags();
26 switch (m_tagStatus) {
29 CPPUNIT_ASSERT_EQUAL(1_st, tags.size());
30 CPPUNIT_ASSERT_EQUAL(
"Sad Song"s, tags.front()->value(KnownField::Title).toString());
31 CPPUNIT_ASSERT_EQUAL(
"Oasis"s, tags.front()->value(KnownField::Artist).toString());
32 CPPUNIT_ASSERT_EQUAL(
"Don't Go Away (Apple Lossless)"s, tags.front()->value(KnownField::Album).toString());
33 CPPUNIT_ASSERT_EQUAL(
"Alternative & Punk"s, tags.front()->value(KnownField::Genre).toString());
34 TESTUTILS_ASSERT_LIKE(
"encoder",
"Lavf.*", tags.front()->value(KnownField::Encoder).toString());
35 CPPUNIT_ASSERT_EQUAL(
"1998"s, tags.front()->value(KnownField::RecordDate).toString());
36 CPPUNIT_ASSERT(tags.front()->value(KnownField::Comment).isEmpty());
39 CPPUNIT_ASSERT_EQUAL(
PositionInSet(3, 4), tags.front()->value(KnownField::TrackPosition).toPositionInSet());
40 CPPUNIT_ASSERT_EQUAL(
PositionInSet(1, 1), tags.front()->value(KnownField::DiskPosition).toPositionInSet());
43 checkOggTestMetaData();
46 CPPUNIT_ASSERT_EQUAL(0_st, tags.size());
49 CPPUNIT_ASSERT(m_diag.
level() <= DiagLevel::Information);
56void OverallTests::checkFlacTestfile2()
58 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Ogg, m_fileInfo.
containerFormat());
59 const auto tracks = m_fileInfo.
tracks();
60 CPPUNIT_ASSERT_EQUAL(1_st, tracks.size());
61 for (
const auto &track : tracks) {
62 CPPUNIT_ASSERT_EQUAL(MediaType::Audio, track->mediaType());
63 CPPUNIT_ASSERT_EQUAL(GeneralMediaFormat::Flac, track->format().general);
64 CPPUNIT_ASSERT_EQUAL(
static_cast<std::uint16_t
>(2), track->channelCount());
65 CPPUNIT_ASSERT_EQUAL(44100u, track->samplingFrequency());
66 CPPUNIT_ASSERT_EQUAL(
static_cast<std::uint16_t
>(16), track->bitsPerSample());
67 CPPUNIT_ASSERT_EQUAL(4, track->duration().minutes());
69 const auto tags = m_fileInfo.
tags();
70 switch (m_tagStatus) {
72 CPPUNIT_ASSERT_EQUAL(1_st, tags.size());
75 checkOggTestMetaData();
78 CPPUNIT_ASSERT_EQUAL(0_st, tags.size());
83 bool gotMessageAboutMissingVorbisComment =
false;
84 for (
const auto &msg : m_diag) {
85 if (msg.level() == DiagLevel::Critical) {
86 CPPUNIT_ASSERT_EQUAL(
"Ogg page after FLAC-to-Ogg mapping header doesn't contain Vorbis comment."s, msg.message());
87 gotMessageAboutMissingVorbisComment =
true;
90 CPPUNIT_ASSERT(msg.level() <= DiagLevel::Information);
92 CPPUNIT_ASSERT(gotMessageAboutMissingVorbisComment);
94 CPPUNIT_ASSERT(m_diag.level() <= DiagLevel::Information);
103 cerr << endl <<
"FLAC parser" << endl;
106 parseFile(testFilePath(
"flac/test.flac"), &OverallTests::checkFlacTestfile1);
107 parseFile(testFilePath(
"flac/test.ogg"), &OverallTests::checkFlacTestfile2);
120 for (m_mode = 0; m_mode != 0x2; ++m_mode) {
126 list<string> testConditions;
127 if (m_mode & RemoveTag) {
128 testConditions.emplace_back(
"removing tag");
130 testConditions.emplace_back(
"modifying tag");
132 cerr << endl <<
"FLAC maker - testmode " << m_mode <<
": " << joinStrings(testConditions,
", ") << endl;
136 void (
OverallTests::*modifyRoutine)(void) = (m_mode & RemoveTag) ? &OverallTests::removeAllTags : &OverallTests::setOggTestMetaData;
137 makeFile(workingCopyPath(
"flac/test.flac"), modifyRoutine, &OverallTests::checkFlacTestfile1);
138 makeFile(workingCopyPath(
"flac/test.ogg"), modifyRoutine, &OverallTests::checkFlacTestfile2);
The OverallTests class tests reading and writing tags and parsing technical information for all suppo...
void testFlacParsing()
Tests the FLAC parser via MediaFileInfo.
void testFlacMaking()
Tests the FLAC maker via MediaFileInfo.
DiagLevel level() const
Returns the worst diag level present in the container.