3 #include "../abstracttrack.h" 4 #include "../mediafileinfo.h" 7 #include <c++utilities/io/catchiofailure.h> 8 #include <c++utilities/tests/testutils.h> 11 #include <cppunit/TestFixture.h> 12 #include <cppunit/extensions/HelperMacros.h> 29 CPPUNIT_TEST(testInitialStatus);
30 CPPUNIT_TEST(testFileSystemMethods);
31 CPPUNIT_TEST(testParsingUnsupportedFile);
32 CPPUNIT_TEST(testFullParseAndFurtherProperties);
33 CPPUNIT_TEST_SUITE_END();
39 void testInitialStatus();
40 void testFileSystemMethods();
41 void testParsingUnsupportedFile();
42 void testPartialParsingAndTagCreationOfMp4File();
44 void testFullParseAndFurtherProperties();
76 CPPUNIT_ASSERT_EQUAL(
"unsupported.bin"s, file.
fileName());
77 CPPUNIT_ASSERT_EQUAL(
"unsupported"s, file.
fileName(
true));
79 CPPUNIT_ASSERT_EQUAL(
".bin"s, file.
extension());
80 CPPUNIT_ASSERT_EQUAL(static_cast<uint64>(0), file.
size());
83 CPPUNIT_ASSERT(file.
isOpen());
85 CPPUNIT_ASSERT_EQUAL(static_cast<uint64>(41), file.
size());
101 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Unknown, file.
containerFormat());
108 MediaFileInfo file(testFilePath(
"mtx-test-data/aac/he-aacv2-ps.m4a"));
116 CPPUNIT_FAIL(
"expected std::ios_base::failure because file has been closed");
129 CPPUNIT_ASSERT_EQUAL(0_st, file.
trackCount());
132 "Parsing attachments is not implemented for the container format of the file.",
"parsing attachments") }),
134 CPPUNIT_ASSERT_EQUAL(DiagLevel::Information, diag.
level());
139 CPPUNIT_ASSERT_EQUAL(0_st, file.
id3v2Tags().size());
141 CPPUNIT_ASSERT(!file.
mp4Tag());
146 CPPUNIT_ASSERT_EQUAL(1_st, file.
id3v2Tags().size());
151 CPPUNIT_ASSERT(file.
mp4Tag());
157 MediaFileInfo file(testFilePath(
"matroska_wave1/test1.mkv"));
168 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Matroska, file.
containerFormat());
174 CPPUNIT_ASSERT_EQUAL(1_st, file.
tags().size());
176 CPPUNIT_ASSERT(!file.
mp4Tag());
179 CPPUNIT_ASSERT_EQUAL(2_st, file.
trackCount());
181 CPPUNIT_ASSERT_EQUAL(0_st, file.
chapters().size());
183 CPPUNIT_ASSERT_EQUAL(0_st, file.
attachments().size());
188 diag.emplace_back(DiagLevel::Warning,
"warning",
"test");
189 CPPUNIT_ASSERT_EQUAL(DiagLevel::Warning, diag.
level());
190 diag.emplace_back(DiagLevel::Critical,
"error",
"test");
191 CPPUNIT_ASSERT_EQUAL(DiagLevel::Critical, diag.
level());
194 file.
tracks().back()->setLanguage(
"eng");
196 CPPUNIT_ASSERT_EQUAL(unordered_set<string>({}), file.
availableLanguages(MediaType::Text));
197 CPPUNIT_ASSERT_EQUAL(
"ID: 2422994868, type: Video"s, file.
tracks()[0]->label());
198 CPPUNIT_ASSERT_EQUAL(
"ID: 3653291187, type: Audio, language: \"eng\""s, file.
tracks()[1]->label());
199 CPPUNIT_ASSERT_EQUAL(
"MS-MPEG-4-480p / MP3-2ch-eng"s, file.
technicalSummary());
static std::string containingDirectory(const std::string &path)
Returns the path of the directory containing the given file.
void open(bool readOnly=false)
Opens a std::fstream for the current file.
void invalidate()
Invalidates the file info manually.
bool isReadOnly() const
Indicates whether the last open()/reopen() call was read-only.
static std::string fileName(const std::string &path, bool cutExtension=false)
Returns the file name of the given file.
Contains utility classes helping to read and write streams.
static std::string extension(const std::string &path)
Returns the extension of the given file.
static std::string pathWithoutExtension(const std::string &fullPath)
Returns a copy of the given path without the extension/suffix.
void reportPathChanged(const std::string &newPath)
Call this function to report that the path changed.
void close()
A possibly opened std::fstream will be closed.
uint64 size() const
Returns size of the current file in bytes.
bool isOpen() const
Indicates whether a std::fstream is open for the current file.