Fix `CliTests::testExtraction()` under Windows

This commit is contained in:
Martchus 2023-08-18 23:56:49 +02:00
parent a2fa2e5561
commit 6f7ee1ea69
1 changed files with 15 additions and 12 deletions

View File

@ -1044,16 +1044,17 @@ void CliTests::testSettingTrackMetaData()
*/ */
void CliTests::testExtraction() void CliTests::testExtraction()
{ {
cout << "\nExtraction" << endl; std::cout << "\nExtraction" << std::endl;
string stdout, stderr; auto stdout = std::string(), stderr = std::string();
const string mp4File1(testFilePath("mtx-test-data/alac/othertest-itunes.m4a")); const auto mp4File1 = testFilePath("mtx-test-data/alac/othertest-itunes.m4a");
const auto tempFile = (std::filesystem::temp_directory_path() / "extracted.jpeg").string();
// test extraction of cover // test extraction of cover
const char *const args1[] = { "tageditor", "extract", "cover", "-f", mp4File1.data(), "-o", "/tmp/extracted.jpeg", nullptr }; const char *const args1[] = { "tageditor", "extract", "cover", "-f", mp4File1.data(), "-o", tempFile.data(), nullptr };
TESTUTILS_ASSERT_EXEC(args1); TESTUTILS_ASSERT_EXEC(args1);
Diagnostics diag; auto diag = Diagnostics();
AbortableProgressFeedback progress; auto progress = AbortableProgressFeedback();
MediaFileInfo extractedInfo("/tmp/extracted.jpeg"sv); auto extractedInfo = MediaFileInfo(tempFile);
extractedInfo.open(true); extractedInfo.open(true);
extractedInfo.parseContainerFormat(diag, progress); extractedInfo.parseContainerFormat(diag, progress);
CPPUNIT_ASSERT_EQUAL(static_cast<std::uint64_t>(22771), extractedInfo.size()); CPPUNIT_ASSERT_EQUAL(static_cast<std::uint64_t>(22771), extractedInfo.size());
@ -1061,17 +1062,19 @@ void CliTests::testExtraction()
extractedInfo.invalidate(); extractedInfo.invalidate();
// test assignment of cover by the way // test assignment of cover by the way
const string mp4File2(workingCopyPath("mtx-test-data/aac/he-aacv2-ps.m4a")); const auto mp4File2 = workingCopyPath("mtx-test-data/aac/he-aacv2-ps.m4a");
const char *const args2[] = { "tageditor", "set", "cover=/tmp/extracted.jpeg", "-f", mp4File2.data(), nullptr }; const auto coverArg = argsToString("cover=", tempFile);
const char *const args2[] = { "tageditor", "set", coverArg.data(), "-f", mp4File2.data(), nullptr };
TESTUTILS_ASSERT_EXEC(args2); TESTUTILS_ASSERT_EXEC(args2);
const char *const args3[] = { "tageditor", "extract", "cover", "-f", mp4File2.data(), "-o", "/tmp/extracted.jpeg", nullptr }; const char *const args3[] = { "tageditor", "extract", "cover", "-f", mp4File2.data(), "-o", tempFile.data(), nullptr };
CPPUNIT_ASSERT_EQUAL(0, remove("/tmp/extracted.jpeg")); CPPUNIT_ASSERT_EQUAL(0, remove(tempFile.data()));
TESTUTILS_ASSERT_EXEC(args3); TESTUTILS_ASSERT_EXEC(args3);
extractedInfo.open(true); extractedInfo.open(true);
extractedInfo.parseContainerFormat(diag, progress); extractedInfo.parseContainerFormat(diag, progress);
CPPUNIT_ASSERT_EQUAL(static_cast<std::uint64_t>(22771), extractedInfo.size()); CPPUNIT_ASSERT_EQUAL(static_cast<std::uint64_t>(22771), extractedInfo.size());
CPPUNIT_ASSERT(ContainerFormat::Jpeg == extractedInfo.containerFormat()); CPPUNIT_ASSERT(ContainerFormat::Jpeg == extractedInfo.containerFormat());
CPPUNIT_ASSERT_EQUAL(0, remove("/tmp/extracted.jpeg")); extractedInfo.close();
CPPUNIT_ASSERT_EQUAL(0, remove(tempFile.data()));
CPPUNIT_ASSERT_EQUAL(0, remove(mp4File2.data())); CPPUNIT_ASSERT_EQUAL(0, remove(mp4File2.data()));
CPPUNIT_ASSERT_EQUAL(0, remove((mp4File2 + ".bak").data())); CPPUNIT_ASSERT_EQUAL(0, remove((mp4File2 + ".bak").data()));
CPPUNIT_ASSERT_EQUAL(Diagnostics(), diag); CPPUNIT_ASSERT_EQUAL(Diagnostics(), diag);