8#include <c++utilities/tests/testutils.h>
11#include <cppunit/TestFixture.h>
12#include <cppunit/extensions/HelperMacros.h>
17using namespace CppUtilities::Literals;
20using namespace CPPUNIT_NS;
32 CPPUNIT_TEST_SUITE_END();
35 void setUp()
override;
75 CPPUNIT_ASSERT_EQUAL(
"unsupported.bin"s, file.
fileName());
76 CPPUNIT_ASSERT_EQUAL(
"unsupported"s, file.
fileName(
true));
78 CPPUNIT_ASSERT_EQUAL(
".bin"s, file.
extension());
79 CPPUNIT_ASSERT_EQUAL(
static_cast<std::uint64_t
>(0), file.
size());
82 CPPUNIT_ASSERT(file.
isOpen());
84 CPPUNIT_ASSERT_EQUAL(
static_cast<std::uint64_t
>(41), file.
size());
107 MediaFileInfo file(testFilePath(
"mtx-test-data/aac/he-aacv2-ps.m4a"));
113 CPPUNIT_ASSERT_THROW_MESSAGE(
"std::ios_base::failure thrown if file closed", file.
parseTracks(diag, progress), std::ios_base::failure);
123 CPPUNIT_ASSERT_EQUAL(0_st, file.
trackCount());
126 "Parsing attachments is not implemented for the container format of the file.",
"parsing attachments") }),
128 CPPUNIT_ASSERT_EQUAL(DiagLevel::Information, diag.
level());
133 CPPUNIT_ASSERT_EQUAL(0_st, file.
id3v2Tags().size());
135 CPPUNIT_ASSERT(!file.
mp4Tag());
140 CPPUNIT_ASSERT_EQUAL(1_st, file.
id3v2Tags().size());
145 CPPUNIT_ASSERT(file.
mp4Tag());
152 MediaFileInfo file(testFilePath(
"matroska_wave1/test1.mkv"));
163 CPPUNIT_ASSERT_EQUAL(ContainerFormat::Matroska, file.
containerFormat());
169 CPPUNIT_ASSERT_EQUAL(1_st, file.
tags().size());
171 CPPUNIT_ASSERT(!file.
mp4Tag());
174 CPPUNIT_ASSERT_EQUAL(2_st, file.
trackCount());
176 CPPUNIT_ASSERT_EQUAL(0_st, file.
chapters().size());
178 CPPUNIT_ASSERT_EQUAL(0_st, file.
attachments().size());
182 CPPUNIT_ASSERT_EQUAL(DiagLevel::None, diag.
level());
183 diag.emplace_back(DiagLevel::Warning,
"warning",
"test");
184 CPPUNIT_ASSERT_EQUAL(DiagLevel::Warning, diag.
level());
185 diag.emplace_back(DiagLevel::Critical,
"error",
"test");
186 CPPUNIT_ASSERT_EQUAL(DiagLevel::Critical, diag.
level());
189 file.
tracks().back()->setLocale(
Locale(
"eng"sv, LocaleFormat::ISO_639_2_B));
191 CPPUNIT_ASSERT_EQUAL(unordered_set<string>({}), file.
availableLanguages(MediaType::Text));
192 CPPUNIT_ASSERT_EQUAL(
"ID: 2422994868, type: Video"s, file.
tracks()[0]->label());
193 CPPUNIT_ASSERT_EQUAL(
"ID: 3653291187, type: Audio, language: English"s, file.
tracks()[1]->label());
194 CPPUNIT_ASSERT_EQUAL(
"MS-MPEG-4-480p / MP3-2ch-eng"s, file.
technicalSummary());
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
static std::string fileName(std::string_view path, bool cutExtension=false)
Returns the file name of the given file.
static std::string extension(std::string_view path)
Returns the extension of the given file.
void reportPathChanged(std::string_view newPath)
Call this function to report that the path changed.
void invalidate()
Invalidates the file info manually.
bool isReadOnly() const
Indicates whether the last open()/reopen() call was read-only.
static std::string containingDirectory(std::string_view path)
Returns the path of the directory containing the given file.
std::uint64_t size() const
Returns size of the current file in bytes.
void open(bool readOnly=false)
Opens a std::fstream for the current file.
static std::string pathWithoutExtension(std::string_view fullPath)
Returns a copy of the given path without the extension/suffix.
void close()
A possibly opened std::fstream will be closed.
bool isOpen() const
Indicates whether a std::fstream is open for the current file.
The DiagMessage class holds an information, warning or error gathered during parsing or making.
The Diagnostics class is a container for DiagMessage.
DiagLevel level() const
Returns the worst diag level present in the container.
Contains all classes and functions of the TagInfo library.
The Locale struct specifies a language and/or a country using one or more LocaleDetail objects.