Remove COD test files, keep empty tests directory
Stripped all platform-specific COD test files (360, PC, PS3, Wii, WiiU). Will rebuild test suite later with new approach. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
1554eb4d74
commit
4ff45f1cac
0
tests/.gitkeep
Normal file
0
tests/.gitkeep
Normal file
@ -1,149 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD10_360 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod10/360";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD10_360::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD10_360::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD10_360::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Decompress: " + fastFilePath;
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 44 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD10_360::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD10_360::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD10_360::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD10_360::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD10";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "360";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD10_360::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod10_360.moc"
|
||||
@ -1,149 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD11_360 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod11/360";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD11_360::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD11_360::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD11_360::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Decompress: " + fastFilePath;
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 44 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD11_360::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD11_360::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD11_360::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD11_360::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD11";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "360";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD11_360::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod11_360.moc"
|
||||
@ -1,267 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD12_360 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod12/360";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD12_360::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD12_360::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD12_360::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Decompress: " + fastFilePath;
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
bool fastFileOpened = testFastFile.open(QIODevice::ReadOnly);
|
||||
if (!fastFileOpened) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(fastFileOpened,
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header;
|
||||
XDataStream fastFileStream(testFFData);
|
||||
|
||||
QByteArray magic(8, Qt::Uninitialized);
|
||||
fastFileStream.readRawData(magic.data(), 8);
|
||||
bool properMagic = magic == "TAff0000";
|
||||
if (!properMagic) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(properMagic,
|
||||
qPrintable("Invalid fastfile magic: " + magic));
|
||||
|
||||
quint32 version;
|
||||
fastFileStream >> version;
|
||||
bool properVersion = version == 606;
|
||||
if (!properVersion) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(properVersion,
|
||||
qPrintable("Invalid fastfile version: " + QString::number(properVersion)));
|
||||
|
||||
fastFileStream.skipRawData(1);
|
||||
|
||||
quint8 compressionFlag, platformFlag, encryptionFlag;
|
||||
fastFileStream >> compressionFlag >> platformFlag >> encryptionFlag;
|
||||
|
||||
bool properCompression = compressionFlag == 1;
|
||||
if (!properCompression)
|
||||
{
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(properCompression,
|
||||
qPrintable("Invalid Fast File Compression: " + QString::number(properVersion) + " Only LZX Fast Files are supported."));
|
||||
|
||||
bool properPlatform = platformFlag == 4;
|
||||
if (!properPlatform)
|
||||
{
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(properPlatform,
|
||||
qPrintable("Invalid Fast File Platform: " + QString::number(properVersion) + " Only 360 Fast Files are supported."));
|
||||
|
||||
bool properEncryption = encryptionFlag == 0;
|
||||
if (!properEncryption)
|
||||
{
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(properEncryption,
|
||||
qPrintable("Encrypted Fast Files are not supported"));
|
||||
|
||||
fastFileStream.device()->seek(144);
|
||||
|
||||
quint64 size;
|
||||
fastFileStream >> size;
|
||||
|
||||
fastFileStream.device()->seek(584);
|
||||
|
||||
QByteArray testZoneData;
|
||||
quint64 consumed = 0;
|
||||
|
||||
while (consumed < size) {
|
||||
/* block header ------------------------------------------------ */
|
||||
quint32 compressedSize, decompressedSize, blockSize, blockPosition;
|
||||
fastFileStream >> compressedSize // DWORD 0
|
||||
>> decompressedSize // DWORD 1
|
||||
>> blockSize // copy of compressedSize
|
||||
>> blockPosition; // DWORD 3
|
||||
|
||||
if (blockPosition != fastFileStream.device()->pos() - 16) {
|
||||
qWarning("Block position mismatch"); break;
|
||||
}
|
||||
|
||||
/* padding block ? --------------------------------------------- */
|
||||
if (decompressedSize == 0) {
|
||||
fastFileStream.skipRawData(
|
||||
((fastFileStream.device()->pos() + 0x7FFFFF) & ~0x7FFFFF) -
|
||||
fastFileStream.device()->pos());
|
||||
continue;
|
||||
}
|
||||
|
||||
/* read LZO slice ---------------------------------------------- */
|
||||
fastFileStream.device()->seek(blockPosition + 16);
|
||||
qDebug() << "Reading block at pos" << blockPosition + 16 << ", compressed:" << compressedSize;
|
||||
|
||||
QByteArray compressedData(compressedSize, Qt::Uninitialized);
|
||||
fastFileStream.readRawData(compressedData.data(), compressedSize);
|
||||
|
||||
qDebug() << "Compressed data:" << compressedData.toHex();
|
||||
|
||||
if (compressedData.at(0) == 'c') {
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray decompressed = Compression::DecompressXMem(compressedData);
|
||||
if (decompressed.isEmpty()) {
|
||||
qWarning() << "Empty decompression output, skipping";
|
||||
continue;
|
||||
}
|
||||
if (!decompressed.left(4).contains('\0')) {
|
||||
qDebug() << "Block starts with" << decompressed.left(16).toHex();
|
||||
}
|
||||
|
||||
testZoneData.append(decompressed);
|
||||
consumed += decompressed.size();
|
||||
|
||||
/* advance to next header (blocks are file-aligned) ------------- */
|
||||
fastFileStream.device()->seek(blockPosition + 16 + blockSize);
|
||||
}
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
bool sizeMatches = zoneSize + 44 == testZoneData.size();
|
||||
if (!sizeMatches) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
//QVERIFY2(sizeMatches,
|
||||
// qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
bool zoneFileOpened = outputFile.open(QIODevice::WriteOnly);
|
||||
if (!zoneFileOpened) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(zoneFileOpened,
|
||||
qPrintable("Failed to open output zone file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD12_360::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD12_360::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD12_360::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD12_360::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
return;
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD12";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "360";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD12_360::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod12_360.moc"
|
||||
@ -1,172 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
#include "fastfile_factory.h"
|
||||
|
||||
class AutoTest_COD2_360 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod2/360";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD2_360::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD2_360::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD2_360::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Decompress: " + fastFilePath;
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
bool fastFileOpened = testFastFile.open(QIODevice::ReadOnly);
|
||||
if (!fastFileOpened) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(fastFileOpened
|
||||
, qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(20);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
// TODO: Find new way to verify as cod2 doesn't store size in zone file
|
||||
//QVERIFY2(zoneSize + 44 == testZoneData.size(),
|
||||
// qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
bool zoneFileOpened = outputFile.open(QIODevice::WriteOnly);
|
||||
if (!zoneFileOpened) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(zoneFileOpened,
|
||||
qPrintable("Failed to open output zone file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD2_360::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD2_360::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
const QString testName = "Compress: " + zoneFilePath;
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
bool zoneFileOpened = zoneFile.open(QIODevice::ReadOnly);
|
||||
if (!zoneFileOpened) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(zoneFileOpened, qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
bool origFileOpened = originalFile.open(QIODevice::ReadOnly);
|
||||
if (!origFileOpened) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(origFileOpened, qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(20);
|
||||
|
||||
QByteArray recompressedData = header + Compression::CompressZLIB(decompressedData);
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
bool fastFileOpened = recompressedFile.open(QIODevice::WriteOnly);
|
||||
if (!fastFileOpened) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(fastFileOpened, qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
bool dataMatches = recompressedData == originalFFData;
|
||||
if (!dataMatches) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD2_360::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD2_360::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD2";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "360";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD2_360::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod2_360.moc"
|
||||
@ -1,152 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
#include "fastfile.h"
|
||||
|
||||
class AutoTest_COD4_360 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod4/360";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD4_360::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD4_360::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD4_360::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Decompress: " + fastFilePath;
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
const QString magic = testFFData.mid(0, 8);
|
||||
QVERIFY2(magic == "IWffu100",
|
||||
qPrintable("Does not support encrypted fastfiles!"));
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::BigEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
if (fabs(zoneSize - testZoneData.size()) != 36) {
|
||||
qDebug() << "Zone Size: " << zoneSize;
|
||||
qDebug() << "Test zone Size: " << testZoneData.size();
|
||||
}
|
||||
QVERIFY2(fabs(zoneSize - testZoneData.size()) == 36,
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD4_360::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD4_360::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD4_360::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD4_360::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD4";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "360";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD4_360::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod4_360.moc"
|
||||
@ -1,155 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "fastfile_factory.h"
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD5_360 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod5/360";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD5_360::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD5_360::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD5_360::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Decompress: " + fastFilePath;
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::BigEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
if (fabs(zoneSize - testZoneData.size()) != 36) {
|
||||
qDebug() << "Zone Size: " << zoneSize;
|
||||
qDebug() << "Test zone Size: " << testZoneData.size();
|
||||
qDebug() << "Difference: " << fabs(zoneSize - testZoneData.size());
|
||||
}
|
||||
QVERIFY2(zoneSize + 36 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD5_360::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD5_360::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_SPEED, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD5_360::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD5_360::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD5";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "360";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD5_360::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod5_360.moc"
|
||||
@ -1,175 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD6_360 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod6/360";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD6_360::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD6_360::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD6_360::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Decompress: " + fastFilePath;
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
const QString magic = testFFData.mid(0, 12);
|
||||
QVERIFY2(magic.contains("IWffu100"),
|
||||
qPrintable("Encountered signed fastfile: " + magic));
|
||||
|
||||
QByteArray pattern;
|
||||
pattern.append(static_cast<unsigned char>(0x78));
|
||||
pattern.append(static_cast<unsigned char>(0xDA));
|
||||
pattern.append(static_cast<unsigned char>(0xEC));
|
||||
|
||||
int index = testFFData.indexOf(pattern);
|
||||
qDebug() << "Zlib Index: " << index;
|
||||
QByteArray compressedData = testFFData.mid(index);
|
||||
QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
//while (index != -1 && testZoneData.isEmpty()) {
|
||||
// compressedData = testFFData.mid(index);
|
||||
// testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// index = testFFData.indexOf(pattern, index + 2);
|
||||
//}
|
||||
|
||||
QVERIFY2(!testZoneData.isEmpty(),
|
||||
qPrintable("Zlib decompression failed!"));
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::BigEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
if (fabs(zoneSize - testZoneData.size()) != 32) {
|
||||
qDebug() << "Zone Size: " << zoneSize;
|
||||
qDebug() << "Test zone Size: " << testZoneData.size();
|
||||
qDebug() << "Difference: " << fabs(zoneSize - testZoneData.size());
|
||||
}
|
||||
QVERIFY2(zoneSize + 32 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD6_360::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD6_360::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray pattern;
|
||||
pattern.append(static_cast<unsigned char>(0x78));
|
||||
pattern.append(static_cast<unsigned char>(0xDA));
|
||||
pattern.append(static_cast<unsigned char>(0xEC));
|
||||
|
||||
int zlibOffset = originalFFData.indexOf(pattern);
|
||||
|
||||
QByteArray header = originalFFData.mid(0, zlibOffset);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD6_360::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD6_360::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD6";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "360";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD6_360::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod6_360.moc"
|
||||
@ -1,190 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
#include "encryption.h"
|
||||
#include "fastfile.h"
|
||||
|
||||
class AutoTest_COD7_360 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod7/360";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD7_360::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD7_360::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD7_360::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Decompress: " + fastFilePath;
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
QByteArray decompressedData;
|
||||
QByteArray key = QByteArray::fromHex("1ac1d12d527c59b40eca619120ff8217ccff09cd16896f81b829c7f52793405d");
|
||||
|
||||
// Create a QDataStream on the input data.
|
||||
QDataStream fastFileStream(testFFData);
|
||||
fastFileStream.setByteOrder(QDataStream::BigEndian);
|
||||
fastFileStream.skipRawData(16);
|
||||
|
||||
// Read the 8-byte magic.
|
||||
QByteArray fileMagic(8, Qt::Uninitialized);
|
||||
fastFileStream.readRawData(fileMagic.data(), 8);
|
||||
QVERIFY2(fileMagic == "PHEEBs71",
|
||||
qPrintable("Invalid fast file magic: " + fileMagic));
|
||||
fastFileStream.skipRawData(4);
|
||||
|
||||
// Read IV table name (32 bytes).
|
||||
QByteArray fileName(32, Qt::Uninitialized);
|
||||
fastFileStream.readRawData(fileName.data(), 32);
|
||||
|
||||
const QByteArray testZoneData = decompressedData;
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
QDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(QDataStream::BigEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
if (fabs(zoneSize - testZoneData.size()) != 36) {
|
||||
qDebug() << "Zone Size: " << zoneSize;
|
||||
qDebug() << "Test zone Size: " << testZoneData.size();
|
||||
qDebug() << "Difference: " << fabs(zoneSize - testZoneData.size());
|
||||
}
|
||||
QVERIFY2(zoneSize + 36 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD7_360::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD7_360::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
const QString testName = "Compress: " + zoneFilePath;
|
||||
|
||||
// Open the original .zone file (decompressed zone data).
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
const QByteArray zoneData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QByteArray compressedData;
|
||||
//QByteArray key = QByteArray::fromHex("1ac1d12d527c59b40eca619120ff8217ccff09cd16896f81b829c7f52793405d");
|
||||
|
||||
// Read the original fastfile header to recover metadata (filename, IV table, etc.)
|
||||
QString ffPath = zoneFilePath;
|
||||
ffPath.replace(".zone", ".ff");
|
||||
QFile originalFF(ffPath);
|
||||
QVERIFY2(originalFF.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open original fastfile: " + ffPath));
|
||||
QByteArray header = originalFF.read(0x13C); // Everything up to section data
|
||||
originalFF.seek(24); // IV Table starts at 24 (after magic + skip + filename)
|
||||
QByteArray fileName(32, Qt::Uninitialized);
|
||||
originalFF.read(fileName.data(), 32);
|
||||
originalFF.close();
|
||||
|
||||
// Rebuild sections from zone data
|
||||
QDataStream zoneStream(zoneData);
|
||||
zoneStream.setByteOrder(QDataStream::BigEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
|
||||
//QByteArray remainingData = zoneData.mid(4); // exclude size field
|
||||
|
||||
QDataStream fastFileStreamOut(&compressedData, QIODevice::WriteOnly);
|
||||
fastFileStreamOut.setByteOrder(QDataStream::BigEndian);
|
||||
|
||||
// Write 0 section size terminator
|
||||
fastFileStreamOut << static_cast<qint32>(0);
|
||||
|
||||
// Combine with header
|
||||
QByteArray fullFastFile = header + compressedData;
|
||||
|
||||
// Save re-encoded fastfile
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + "_recompressed.ff";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(fullFastFile);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD7_360::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD7_360::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD7";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "360";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD7_360::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod7_360.moc"
|
||||
@ -1,168 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD8_360 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod8/360";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD8_360::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD8_360::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD8_360::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Decompress: " + fastFilePath;
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
QByteArray pattern;
|
||||
pattern.append(static_cast<unsigned char>(0xFF));
|
||||
|
||||
QByteArray testZoneData;
|
||||
|
||||
for (int i = 12; i < testFFData.size(); i++) {
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(i);
|
||||
testZoneData = Compression::DecompressXMem(compressedData);
|
||||
//QVERIFY2(!testZoneData.isEmpty(), qPrintable("Result was empty!"));
|
||||
|
||||
if (!testZoneData.isEmpty()) {
|
||||
qDebug() << QString("Suceeded at %1!").arg(i);
|
||||
//break;
|
||||
}
|
||||
qDebug() << QString("Failed at %1!").arg(i);
|
||||
}
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
if (fabs(zoneSize - testZoneData.size()) != 44) {
|
||||
qDebug() << "Zone Size: " << zoneSize;
|
||||
qDebug() << "Test zone Size: " << testZoneData.size();
|
||||
qDebug() << "Difference: " << fabs(zoneSize - testZoneData.size());
|
||||
}
|
||||
//QVERIFY2(zoneSize + 44 == testZoneData.size(),
|
||||
// qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD8_360::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD8_360::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD8_360::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD8_360::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD8";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "360";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD8_360::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod8_360.moc"
|
||||
@ -1,149 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD9_360 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod9/360";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD9_360::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD9_360::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD9_360::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Decompress: " + fastFilePath;
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 44 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD9_360::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD9_360::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD9_360::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD9_360::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD9";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "360";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD9_360::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod9_360.moc"
|
||||
@ -1,145 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD10_PC : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod8/pc";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD10_PC::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD10_PC::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD10_PC::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 36 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD10_PC::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD10_PC::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
QByteArray newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_SPEED);
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD10_PC::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD10_PC::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD10";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PC";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD10_PC::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod10_pc.moc"
|
||||
@ -1,145 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD11_PC : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod11/pc";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD11_PC::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD11_PC::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD11_PC::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 36 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD11_PC::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD11_PC::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
QByteArray newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_SPEED);
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD11_PC::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD11_PC::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD11";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PC";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD11_PC::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod11_pc.moc"
|
||||
@ -1,238 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD12_PC : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod12/pc";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD12_PC::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD12_PC::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD12_PC::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Decompress: " + fastFilePath;
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
bool fastFileOpened = testFastFile.open(QIODevice::ReadOnly);
|
||||
if (!fastFileOpened) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(fastFileOpened,
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
XDataStream fastFileStream(testFFData);
|
||||
fastFileStream.setByteOrder(XDataStream::LittleEndian);
|
||||
|
||||
QByteArray magic(8, Qt::Uninitialized);
|
||||
fastFileStream.readRawData(magic.data(), 8);
|
||||
bool properMagic = magic == "TAff0000";
|
||||
if (!properMagic) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(properMagic,
|
||||
qPrintable("Invalid fastfile magic: " + magic));
|
||||
|
||||
quint32 version;
|
||||
fastFileStream >> version;
|
||||
bool properVersion = version == 593;
|
||||
if (!properVersion) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(properVersion,
|
||||
qPrintable("Invalid fastfile version: " + QString::number(properVersion)));
|
||||
|
||||
fastFileStream.skipRawData(1);
|
||||
|
||||
quint8 compressionFlag, platformFlag, encryptionFlag;
|
||||
fastFileStream >> compressionFlag >> platformFlag >> encryptionFlag;
|
||||
|
||||
bool properCompression = compressionFlag == 1;
|
||||
if (!properCompression)
|
||||
{
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(properCompression,
|
||||
qPrintable("Invalid Fast File Compression: " + QString::number(properVersion) + " Only ZLIB Fast Files are supported."));
|
||||
|
||||
bool properPlatform = platformFlag == 0;
|
||||
if (!properPlatform)
|
||||
{
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(properPlatform,
|
||||
qPrintable("Invalid Fast File Platform: " + QString::number(properVersion) + " Only PC Fast Files are supported."));
|
||||
|
||||
bool properEncryption = encryptionFlag == 0;
|
||||
if (!properEncryption)
|
||||
{
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(properEncryption,
|
||||
qPrintable("Encrypted Fast Files are not supported"));
|
||||
|
||||
fastFileStream.device()->seek(144);
|
||||
|
||||
quint64 size;
|
||||
fastFileStream >> size;
|
||||
|
||||
fastFileStream.device()->seek(584);
|
||||
|
||||
QByteArray testZoneData;
|
||||
int consumed = 0;
|
||||
while (consumed < size) {
|
||||
quint32 compressedSize, decompressedSize, blockSize, blockPosition;
|
||||
fastFileStream >> compressedSize >> decompressedSize >> blockSize >> blockPosition;
|
||||
|
||||
if (blockPosition != fastFileStream.device()->pos() - 16) {
|
||||
qDebug() << "Block position does not match stream position!";
|
||||
break;
|
||||
}
|
||||
|
||||
if (decompressedSize == 0) {
|
||||
fastFileStream.skipRawData((((fastFileStream.device()->pos()) + ((0x800000) - 1)) & ~((0x800000) - 1)) - fastFileStream.device()->pos());
|
||||
continue;
|
||||
}
|
||||
|
||||
fastFileStream.skipRawData(2);
|
||||
QByteArray compressedData(compressedSize - 2, Qt::Uninitialized);
|
||||
fastFileStream.readRawData(compressedData.data(), compressedSize - 2);
|
||||
testZoneData.append(Compression::DecompressDeflate(compressedData));
|
||||
|
||||
consumed += decompressedSize;
|
||||
fastFileStream.device()->seek(blockPosition + 16 + blockSize);
|
||||
}
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
bool sizeMatches = zoneSize + 44 == testZoneData.size();
|
||||
if (!sizeMatches) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
//QVERIFY2(sizeMatches,
|
||||
// qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
bool zoneFileOpened = outputFile.open(QIODevice::WriteOnly);
|
||||
if (!zoneFileOpened) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(zoneFileOpened,
|
||||
qPrintable("Failed to open output zone file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD12_PC::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD12_PC::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
QByteArray newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_SPEED);
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD12_PC::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD12_PC::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD12";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PC";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD12_PC::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod12_pc.moc"
|
||||
@ -1,142 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
|
||||
class AutoTest_COD4_PC : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod4/pc";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD4_PC::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD4_PC::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD4_PC::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 44 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD4_PC::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD4_PC::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD4_PC::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD4_PC::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD4";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PC";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD4_PC::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod4_pc.moc"
|
||||
@ -1,146 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD5_PC : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod5/pc";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD5_PC::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD5_PC::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD5_PC::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 36 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD5_PC::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD5_PC::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_SPEED);
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD5_PC::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD5_PC::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD5";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PC";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD5_PC::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod5_pc.moc"
|
||||
@ -1,138 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD6_PC : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod6/pc";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD6_PC::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD6_PC::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD6_PC::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(21);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 40 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD6_PC::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD6_PC::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(21);
|
||||
QByteArray newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION);
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD6_PC::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD6_PC::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD6";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PC";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD6_PC::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod6_pc.moc"
|
||||
@ -1,145 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD7_PC : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod7/pc";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD7_PC::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD7_PC::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD7_PC::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 36 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD7_PC::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD7_PC::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
QByteArray newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_SPEED);
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD7_PC::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD7_PC::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD7";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PC";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD7_PC::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod7_pc.moc"
|
||||
@ -1,145 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD8_PC : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod8/pc";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD8_PC::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD8_PC::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD8_PC::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 36 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD8_PC::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD8_PC::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
QByteArray newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_SPEED);
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD8_PC::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD8_PC::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD8";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PC";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD8_PC::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod8_pc.moc"
|
||||
@ -1,145 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD9_PC : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod9/pc";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD9_PC::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD9_PC::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD9_PC::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 36 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD9_PC::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD9_PC::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
QByteArray newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_SPEED);
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD9_PC::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD9_PC::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD9";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PC";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD9_PC::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod9_pc.moc"
|
||||
@ -1,147 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD10_PS3 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod10/PS3";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD10_PS3::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD10_PS3::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD10_PS3::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 44 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD10_PS3::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD10_PS3::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD10_PS3::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD10_PS3::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD10";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PS3";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD10_PS3::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod10_ps3.moc"
|
||||
@ -1,147 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD11_PS3 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod11/PS3";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD11_PS3::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD11_PS3::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD11_PS3::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 44 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD11_PS3::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD11_PS3::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD11_PS3::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD11_PS3::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD11";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PS3";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD11_PS3::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod11_ps3.moc"
|
||||
@ -1,240 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD12_PS3 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod12/PS3";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD12_PS3::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD12_PS3::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD12_PS3::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Decompress: " + fastFilePath;
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
bool fastFileOpened = testFastFile.open(QIODevice::ReadOnly);
|
||||
if (!fastFileOpened) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(fastFileOpened,
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
XDataStream fastFileStream(testFFData);
|
||||
fastFileStream.setByteOrder(XDataStream::BigEndian);
|
||||
|
||||
QByteArray magic(8, Qt::Uninitialized);
|
||||
fastFileStream.readRawData(magic.data(), 8);
|
||||
bool properMagic = magic == "TAff00PS";
|
||||
if (!properMagic) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(properMagic,
|
||||
qPrintable("Invalid fastfile magic: " + magic));
|
||||
|
||||
quint32 version;
|
||||
fastFileStream >> version;
|
||||
bool properVersion = version == 595;
|
||||
if (!properVersion) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(properVersion,
|
||||
qPrintable("Invalid fastfile version: " + QString::number(properVersion)));
|
||||
|
||||
fastFileStream.skipRawData(1);
|
||||
|
||||
quint8 compressionFlag, platformFlag, encryptionFlag;
|
||||
fastFileStream >> compressionFlag >> platformFlag >> encryptionFlag;
|
||||
|
||||
bool properCompression = compressionFlag == 1;
|
||||
if (!properCompression)
|
||||
{
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(properCompression,
|
||||
qPrintable("Invalid Fast File Compression: " + QString::number(properVersion) + " Only ZLIB Fast Files are supported."));
|
||||
|
||||
bool properPlatform = platformFlag == 3;
|
||||
if (!properPlatform)
|
||||
{
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(properPlatform,
|
||||
qPrintable("Invalid Fast File Platform: " + QString::number(properVersion) + " Only PS3 Fast Files are supported."));
|
||||
|
||||
bool properEncryption = encryptionFlag == 0;
|
||||
if (!properEncryption)
|
||||
{
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(properEncryption,
|
||||
qPrintable("Encrypted Fast Files are not supported"));
|
||||
|
||||
fastFileStream.device()->seek(144);
|
||||
|
||||
quint64 size;
|
||||
fastFileStream >> size;
|
||||
|
||||
fastFileStream.device()->seek(584);
|
||||
|
||||
QByteArray testZoneData;
|
||||
int consumed = 0;
|
||||
while (consumed < size) {
|
||||
quint32 compressedSize, decompressedSize, blockSize, blockPosition;
|
||||
fastFileStream >> compressedSize >> decompressedSize >> blockSize >> blockPosition;
|
||||
|
||||
if (blockPosition != fastFileStream.device()->pos() - 16) {
|
||||
qDebug() << "Block position does not match stream position!";
|
||||
break;
|
||||
}
|
||||
|
||||
if (decompressedSize == 0) {
|
||||
fastFileStream.skipRawData((((fastFileStream.device()->pos()) + ((0x800000) - 1)) & ~((0x800000) - 1)) - fastFileStream.device()->pos());
|
||||
continue;
|
||||
}
|
||||
|
||||
fastFileStream.skipRawData(2);
|
||||
QByteArray compressedData(compressedSize - 2, Qt::Uninitialized);
|
||||
fastFileStream.readRawData(compressedData.data(), compressedSize - 2);
|
||||
testZoneData.append(Compression::DecompressDeflate(compressedData));
|
||||
|
||||
consumed += decompressedSize;
|
||||
fastFileStream.device()->seek(blockPosition + 16 + blockSize);
|
||||
}
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
bool sizeMatches = zoneSize + 44 == testZoneData.size();
|
||||
if (!sizeMatches) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
//QVERIFY2(sizeMatches,
|
||||
// qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
bool zoneFileOpened = outputFile.open(QIODevice::WriteOnly);
|
||||
if (!zoneFileOpened) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(zoneFileOpened,
|
||||
qPrintable("Failed to open output zone file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD12_PS3::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD12_PS3::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD12_PS3::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD12_PS3::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD12";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PS3";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD12_PS3::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod12_ps3.moc"
|
||||
@ -1,186 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD4_PS3 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod4/PS3";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD4_PS3::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD4_PS3::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD4_PS3::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Validate header
|
||||
QVERIFY2(testFFData.size() > 12, "FastFile too small to contain header");
|
||||
QByteArray header = testFFData.left(8);
|
||||
QVERIFY2(header == "IWffu100", "Invalid FastFile header!");
|
||||
|
||||
XDataStream headerStream(testFFData.mid(8, 6));
|
||||
headerStream.setByteOrder(XDataStream::BigEndian);
|
||||
qint32 version;
|
||||
qint16 identifier;
|
||||
headerStream >> version >> identifier;
|
||||
QVERIFY2(version == 1, "Unsupported game version");
|
||||
|
||||
QByteArray decompressed;
|
||||
int pos = 12;
|
||||
|
||||
// Loop until EOF or invalid chunk
|
||||
while (pos <= testFFData.size()) {
|
||||
// Read 2-byte BIG-ENDIAN chunk size
|
||||
quint32 chunkSize;
|
||||
XDataStream chunkStream(testFFData.mid(pos, 2));
|
||||
chunkStream.setByteOrder(XDataStream::BigEndian);
|
||||
chunkStream >> chunkSize;
|
||||
|
||||
pos += 2;
|
||||
|
||||
if (chunkSize == 0 || pos + chunkSize > testFFData.size()) {
|
||||
qWarning() << "Invalid or incomplete chunk detected, stopping.";
|
||||
break;
|
||||
}
|
||||
|
||||
const QByteArray compressedChunk = testFFData.mid(pos, chunkSize);
|
||||
|
||||
decompressed.append(Compression::DecompressDeflate(compressedChunk));
|
||||
|
||||
pos += chunkSize;
|
||||
}
|
||||
|
||||
// Write decompressed .zone file
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(decompressed);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
|
||||
void AutoTest_COD4_PS3::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD4_PS3::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
QByteArray recompressedData = header;
|
||||
|
||||
// Split decompressed data into chunks (optional: same size as original or fixed 0x4000)
|
||||
const int chunkSize = 0x4000;
|
||||
int offset = 0;
|
||||
|
||||
while (offset < decompressedData.size()) {
|
||||
QByteArray chunk = decompressedData.mid(offset, chunkSize);
|
||||
offset += chunk.size();
|
||||
|
||||
QByteArray compressedChunk = Compression::CompressDeflate(chunk);
|
||||
quint32 length = static_cast<quint32>(compressedChunk.size());
|
||||
|
||||
// Write 2-byte big-endian chunk size
|
||||
recompressedData.append(static_cast<char>((length >> 8) & 0xFF));
|
||||
recompressedData.append(static_cast<char>(length & 0xFF));
|
||||
|
||||
// Write compressed chunk
|
||||
recompressedData.append(compressedChunk);
|
||||
}
|
||||
|
||||
// No terminator chunk needed if original didn't have one
|
||||
|
||||
// Save new file
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
// Validate byte-for-byte match
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
|
||||
void AutoTest_COD4_PS3::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD4_PS3::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD4";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PS3";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD4_PS3::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod4_ps3.moc"
|
||||
@ -1,184 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD5_PS3 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod5/PS3";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD5_PS3::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD5_PS3::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD5_PS3::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Validate header
|
||||
QVERIFY2(testFFData.size() > 12, "FastFile too small to contain header");
|
||||
QByteArray header = testFFData.left(8);
|
||||
QVERIFY2(header == "IWffu100", "Invalid FastFile header!");
|
||||
|
||||
XDataStream headerStream(testFFData.mid(8, 6));
|
||||
headerStream.setByteOrder(XDataStream::BigEndian);
|
||||
qint32 version;
|
||||
qint16 identifier;
|
||||
headerStream >> version >> identifier;
|
||||
QVERIFY2(version == 387, "Unsupported game version");
|
||||
|
||||
QByteArray decompressed;
|
||||
int pos = 12;
|
||||
|
||||
// Loop until EOF or invalid chunk
|
||||
while (pos <= testFFData.size()) {
|
||||
// Read 2-byte BIG-ENDIAN chunk size
|
||||
quint32 chunkSize;
|
||||
XDataStream chunkStream(testFFData.mid(pos, 2));
|
||||
chunkStream.setByteOrder(XDataStream::BigEndian);
|
||||
chunkStream >> chunkSize;
|
||||
|
||||
pos += 2;
|
||||
|
||||
if (chunkSize == 0 || pos + chunkSize > testFFData.size()) {
|
||||
qWarning() << "Invalid or incomplete chunk detected, stopping.";
|
||||
break;
|
||||
}
|
||||
|
||||
const QByteArray compressedChunk = testFFData.mid(pos, chunkSize);
|
||||
|
||||
decompressed.append(Compression::DecompressDeflate(compressedChunk));
|
||||
|
||||
pos += chunkSize;
|
||||
}
|
||||
|
||||
// Write decompressed .zone file
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(decompressed);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD5_PS3::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD5_PS3::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
QByteArray recompressedData = header;
|
||||
|
||||
// Split decompressed data into chunks (optional: same size as original or fixed 0x4000)
|
||||
const int chunkSize = 0x4000;
|
||||
int offset = 0;
|
||||
|
||||
while (offset < decompressedData.size()) {
|
||||
QByteArray chunk = decompressedData.mid(offset, chunkSize);
|
||||
offset += chunk.size();
|
||||
|
||||
QByteArray compressedChunk = Compression::CompressDeflate(chunk);
|
||||
quint32 length = static_cast<quint32>(compressedChunk.size());
|
||||
|
||||
// Write 2-byte big-endian chunk size
|
||||
recompressedData.append(static_cast<char>((length >> 8) & 0xFF));
|
||||
recompressedData.append(static_cast<char>(length & 0xFF));
|
||||
|
||||
// Write compressed chunk
|
||||
recompressedData.append(compressedChunk);
|
||||
}
|
||||
|
||||
// No terminator chunk needed if original didn't have one
|
||||
|
||||
// Save new file
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
// Validate byte-for-byte match
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD5_PS3::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD5_PS3::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD5";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PS3";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD5_PS3::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod5_ps3.moc"
|
||||
@ -1,147 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD6_PS3 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod6/PS3";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD6_PS3::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD6_PS3::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD6_PS3::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 44 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD6_PS3::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD6_PS3::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD6_PS3::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD6_PS3::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD6";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PS3";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD6_PS3::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod6_ps3.moc"
|
||||
@ -1,174 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
#include "encryption.h"
|
||||
#include "fastfile.h"
|
||||
#include "xdatastream.h"
|
||||
|
||||
class AutoTest_COD7_PS3 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod7/PS3";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD7_PS3::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD7_PS3::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD7_PS3::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Decompress: " + fastFilePath;
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
QByteArray decompressedData;
|
||||
QByteArray key = QByteArray::fromHex("46D3F997F29C9ACE175B0DAE3AB8C0C1B8E423E2E3BF7E3C311EA35245BF193A");
|
||||
|
||||
// Create a XDataStream on the input data.
|
||||
XDataStream fastFileStream(testFFData);
|
||||
fastFileStream.setByteOrder(XDataStream::BigEndian);
|
||||
fastFileStream.skipRawData(16);
|
||||
|
||||
// Read the 8-byte magic.
|
||||
QByteArray fileMagic(8, Qt::Uninitialized);
|
||||
fastFileStream.readRawData(fileMagic.data(), 8);
|
||||
QVERIFY2(fileMagic == "PHEEBs71",
|
||||
qPrintable("Invalid fast file magic: " + fileMagic));
|
||||
fastFileStream.skipRawData(4);
|
||||
|
||||
// Read IV table name (32 bytes).
|
||||
QByteArray fileName(32, Qt::Uninitialized);
|
||||
fastFileStream.readRawData(fileName.data(), 32);
|
||||
|
||||
const QByteArray testZoneData = decompressedData;
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::BigEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
if (fabs(zoneSize - testZoneData.size()) != 36) {
|
||||
qDebug() << "Zone Size: " << zoneSize;
|
||||
qDebug() << "Test zone Size: " << testZoneData.size();
|
||||
qDebug() << "Difference: " << fabs(zoneSize - testZoneData.size());
|
||||
}
|
||||
QVERIFY2(zoneSize + 36 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD7_PS3::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD7_PS3::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD7_PS3::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD7_PS3::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD7";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PS3";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD7_PS3::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod7_ps3.moc"
|
||||
@ -1,147 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD8_PS3 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod8/PS3";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD8_PS3::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD8_PS3::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD8_PS3::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 44 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD8_PS3::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD8_PS3::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD8_PS3::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD8_PS3::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD8";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PS3";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD8_PS3::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod8_ps3.moc"
|
||||
@ -1,147 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD9_PS3 : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod9/PS3";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD9_PS3::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD9_PS3::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD9_PS3::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 44 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD9_PS3::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD9_PS3::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD9_PS3::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD9_PS3::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD9";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "PS3";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD9_PS3::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod9_ps3.moc"
|
||||
@ -1,146 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD4_Wii : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod4/Wii";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD4_Wii::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD4_Wii::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD4_Wii::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::BigEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 40 == testZoneData.size(),
|
||||
qPrintable(QString("Decompression validation failed, got [%1] expected [%2]").arg(zoneSize + 40).arg(testZoneData.size())));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD4_Wii::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD4_Wii::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_SPEED);
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD4_Wii::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD4_Wii::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD4";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "Wii";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD4_Wii::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod4_wii.moc"
|
||||
@ -1,146 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD7_Wii : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod7/Wii";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD7_Wii::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD7_Wii::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD7_Wii::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::BigEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 40 == testZoneData.size(),
|
||||
qPrintable(QString("Decompression validation failed, got [%1] expected [%2]").arg(zoneSize + 40).arg(testZoneData.size())));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD7_Wii::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD7_Wii::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_SPEED);
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD7_Wii::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD7_Wii::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD7";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "Wii";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD7_Wii::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod7_wii.moc"
|
||||
@ -1,138 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD8_Wii : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod8/Wii";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD8_Wii::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD8_Wii::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD8_Wii::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(25);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::BigEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 32 == testZoneData.size(),
|
||||
qPrintable(QString("Decompression validation failed, got [%1] expected [%2]").arg(zoneSize + 32).arg(testZoneData.size())));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD8_Wii::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD8_Wii::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(25);
|
||||
QByteArray newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_SPEED);
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD8_Wii::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD8_Wii::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD8";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "Wii";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD8_Wii::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod8_wii.moc"
|
||||
@ -1,147 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD10_WiiU : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod10/WiiU";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD10_WiiU::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD10_WiiU::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD10_WiiU::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 44 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD10_WiiU::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD10_WiiU::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD10_WiiU::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD10_WiiU::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD10";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "WiiU";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD10_WiiU::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod10_wiiu.moc"
|
||||
@ -1,147 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "autotest_cod.h"
|
||||
#include "compression.h"
|
||||
|
||||
class AutoTest_COD9_WiiU : public AutoTest_COD {
|
||||
Q_OBJECT
|
||||
|
||||
const QString EXPORT_DIR = "./exports/cod9/WiiU";
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testDecompression_data();
|
||||
void testDecompression();
|
||||
|
||||
void testCompression_data();
|
||||
void testCompression();
|
||||
|
||||
void testFactory_data();
|
||||
void testFactory();
|
||||
|
||||
void cleanupTestCase();
|
||||
};
|
||||
|
||||
void AutoTest_COD9_WiiU::initTestCase() {
|
||||
// Ensure the exports directory exists.
|
||||
createDirectory(EXPORT_DIR);
|
||||
}
|
||||
|
||||
void AutoTest_COD9_WiiU::testDecompression_data() {
|
||||
AutoTest_COD::testDecompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD9_WiiU::testDecompression() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
// Open the original .ff file.
|
||||
QFile testFastFile(fastFilePath);
|
||||
QVERIFY2(testFastFile.open(QIODevice::ReadOnly),
|
||||
qPrintable("Failed to open test fastfile: " + fastFilePath));
|
||||
const QByteArray testFFData = testFastFile.readAll();
|
||||
testFastFile.close();
|
||||
|
||||
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
||||
const QByteArray compressedData = testFFData.mid(12);
|
||||
const QByteArray testZoneData = Compression::DecompressZLIB(compressedData);
|
||||
|
||||
// Verify the decompressed data via its embedded zone size.
|
||||
XDataStream zoneStream(testZoneData);
|
||||
zoneStream.setByteOrder(XDataStream::LittleEndian);
|
||||
quint32 zoneSize;
|
||||
zoneStream >> zoneSize;
|
||||
QVERIFY2(zoneSize + 44 == testZoneData.size(),
|
||||
qPrintable("Decompression validation failed for: " + fastFilePath));
|
||||
|
||||
// Write the decompressed zone data to the exports folder with a .zone extension.
|
||||
QFileInfo fi(fastFilePath);
|
||||
QString outputFileName = fi.completeBaseName() + ".zone";
|
||||
QString outputFilePath = QDir(EXPORT_DIR).filePath(outputFileName);
|
||||
QFile outputFile(outputFilePath);
|
||||
QVERIFY2(outputFile.open(QIODevice::WriteOnly),
|
||||
qPrintable("Failed to open output file for writing: " + outputFilePath));
|
||||
outputFile.write(testZoneData);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
void AutoTest_COD9_WiiU::testCompression_data() {
|
||||
AutoTest_COD::testCompression_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD9_WiiU::testCompression() {
|
||||
QFETCH(QString, zoneFilePath);
|
||||
|
||||
QFile zoneFile(zoneFilePath);
|
||||
QVERIFY2(zoneFile.open(QIODevice::ReadOnly), qPrintable("Failed to open zone file: " + zoneFilePath));
|
||||
QByteArray decompressedData = zoneFile.readAll();
|
||||
zoneFile.close();
|
||||
|
||||
QFileInfo fi(zoneFilePath);
|
||||
QString originalFFPath = QDir(getFastFileDirectory()).filePath(fi.completeBaseName() + ".ff");
|
||||
|
||||
QFile originalFile(originalFFPath);
|
||||
QVERIFY2(originalFile.open(QIODevice::ReadOnly), qPrintable("Failed to open original .ff file: " + originalFFPath));
|
||||
QByteArray originalFFData = originalFile.readAll();
|
||||
originalFile.close();
|
||||
|
||||
QByteArray header = originalFFData.left(12);
|
||||
|
||||
QByteArray newCompressedData;// = Compressor::CompressZLIB(decompressedData, Z_BEST_COMPRESSION);
|
||||
newCompressedData = Compression::CompressZLIBWithSettings(decompressedData, Z_BEST_COMPRESSION, MAX_WBITS, 8, Z_DEFAULT_STRATEGY, {});
|
||||
|
||||
int remainder = (newCompressedData.size() + 12) % 32;
|
||||
if (remainder != 0) {
|
||||
int paddingNeeded = 32 - remainder;
|
||||
newCompressedData.append(QByteArray(paddingNeeded, '\0'));
|
||||
}
|
||||
|
||||
QByteArray recompressedData = header + newCompressedData;
|
||||
|
||||
QString recompressedFilePath = QDir(EXPORT_DIR).filePath(fi.completeBaseName() + ".ff");
|
||||
QFile recompressedFile(recompressedFilePath);
|
||||
QVERIFY2(recompressedFile.open(QIODevice::WriteOnly), qPrintable("Failed to write recompressed file."));
|
||||
recompressedFile.write(recompressedData);
|
||||
recompressedFile.close();
|
||||
|
||||
QCOMPARE(recompressedData, originalFFData);
|
||||
}
|
||||
|
||||
void AutoTest_COD9_WiiU::testFactory_data() {
|
||||
AutoTest_COD::testFactory_data();
|
||||
}
|
||||
|
||||
void AutoTest_COD9_WiiU::testFactory() {
|
||||
QFETCH(QString, fastFilePath);
|
||||
|
||||
const QString testName = "Factory ingest: " + fastFilePath;
|
||||
|
||||
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||
|
||||
const QString game = fastFile->GetGame();
|
||||
bool correctGame = game == "COD9";
|
||||
if (!correctGame) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctGame
|
||||
, qPrintable("Factory parsed wrong game [" + game + "] for fastfile: " + fastFilePath));
|
||||
|
||||
const QString platform = fastFile->GetPlatform();
|
||||
bool correctPlatform = platform == "WiiU";
|
||||
if (!correctPlatform) {
|
||||
recordResult(testName, false);
|
||||
}
|
||||
QVERIFY2(correctPlatform
|
||||
, qPrintable("Factory parsed wrong platform [" + platform + "] for fastfile: " + fastFilePath));
|
||||
|
||||
recordResult(testName, true);
|
||||
}
|
||||
|
||||
void AutoTest_COD9_WiiU::cleanupTestCase() {
|
||||
// Any cleanup if necessary.
|
||||
}
|
||||
|
||||
// Don't generate a main() function
|
||||
#include "autotest_cod9_wiiu.moc"
|
||||
@ -1,109 +0,0 @@
|
||||
#include "autotest_cod.h"
|
||||
|
||||
const QList<QPair<QString, bool> > &AutoTest_COD::getCollectedTestResults() const {
|
||||
return m_subtestResults;
|
||||
}
|
||||
|
||||
void AutoTest_COD::recordResult(const QString &name, bool passed) {
|
||||
m_subtestResults.append({ name, passed });
|
||||
}
|
||||
|
||||
void AutoTest_COD::setFastFileDirectory(const QString aFastFileDir) {
|
||||
mFastFileDirectory = aFastFileDir;
|
||||
}
|
||||
|
||||
QString AutoTest_COD::getFastFileDirectory() {
|
||||
return mFastFileDirectory;
|
||||
}
|
||||
|
||||
void AutoTest_COD::setZoneFileDirectory(const QString aZoneFileDir) {
|
||||
mZoneFileDirectory = aZoneFileDir;
|
||||
}
|
||||
|
||||
QString AutoTest_COD::getZoneFileDirectory() {
|
||||
return mZoneFileDirectory;
|
||||
}
|
||||
|
||||
void AutoTest_COD::createDirectory(const QString aDir) {
|
||||
QDir newDir(".");
|
||||
newDir.mkpath(aDir);
|
||||
}
|
||||
|
||||
QStringList AutoTest_COD::findZoneFiles(const QString &aBaseDir, int aMaxIter) {
|
||||
QList<QPair<qint64, QString>> fileList;
|
||||
|
||||
QDirIterator it(aBaseDir, QStringList() << "*.zone", QDir::Files, QDirIterator::Subdirectories);
|
||||
int i = 0;
|
||||
while (it.hasNext() && i < aMaxIter) {
|
||||
QString path = it.next();
|
||||
QFileInfo fi(path);
|
||||
fileList.append(qMakePair(fi.size(), path));
|
||||
++i;
|
||||
}
|
||||
|
||||
std::sort(fileList.begin(), fileList.end(),
|
||||
[](const QPair<qint64, QString> &a, const QPair<qint64, QString> &b) {
|
||||
return a.first < b.first; // sort by size
|
||||
});
|
||||
|
||||
QStringList sorted;
|
||||
for (const auto &pair : fileList)
|
||||
sorted << pair.second;
|
||||
|
||||
return sorted;
|
||||
}
|
||||
|
||||
QStringList AutoTest_COD::findFastFiles(const QString &aBaseDir, int aMaxIter) {
|
||||
QList<QPair<qint64, QString>> fileList;
|
||||
|
||||
QDirIterator it(aBaseDir, QStringList() << "*.ff", QDir::Files, QDirIterator::Subdirectories);
|
||||
int i = 0;
|
||||
while (it.hasNext() && i < aMaxIter) {
|
||||
QString path = it.next();
|
||||
QFileInfo fi(path);
|
||||
fileList.append(qMakePair(fi.size(), path));
|
||||
++i;
|
||||
}
|
||||
|
||||
std::sort(fileList.begin(), fileList.end(),
|
||||
[](const QPair<qint64, QString> &a, const QPair<qint64, QString> &b) {
|
||||
return a.first < b.first; // sort by size
|
||||
});
|
||||
|
||||
QStringList sorted;
|
||||
for (const auto &pair : fileList)
|
||||
sorted << pair.second;
|
||||
|
||||
return sorted;
|
||||
}
|
||||
|
||||
void AutoTest_COD::testDecompression_data() {
|
||||
QTest::addColumn<QString>("fastFilePath");
|
||||
|
||||
QStringList ffFiles = findFastFiles(getFastFileDirectory());
|
||||
for (const QString &filePath : ffFiles) {
|
||||
QString fileName = QFileInfo(filePath).fileName();
|
||||
QTest::newRow(qPrintable(fileName)) << filePath;
|
||||
}
|
||||
}
|
||||
|
||||
void AutoTest_COD::testCompression_data() {
|
||||
QTest::addColumn<QString>("zoneFilePath");
|
||||
|
||||
QStringList zoneFiles = findZoneFiles(getZoneFileDirectory());
|
||||
for (const QString &filePath : zoneFiles) {
|
||||
QString fileName = QFileInfo(filePath).fileName();
|
||||
QTest::newRow(qPrintable(fileName)) << filePath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AutoTest_COD::testFactory_data() {
|
||||
QTest::addColumn<QString>("fastFilePath");
|
||||
|
||||
QStringList ffFiles = findFastFiles(getFastFileDirectory());
|
||||
for (const QString &filePath : ffFiles) {
|
||||
QString fileName = QFileInfo(filePath).fileName();
|
||||
QTest::newRow(qPrintable(fileName)) << filePath;
|
||||
}
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
#ifndef AUTOTEST_COD_CPP
|
||||
#define AUTOTEST_COD_CPP
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#define FILE_MAX 3
|
||||
|
||||
class AutoTest_COD : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
QList<QPair<QString, bool>> m_subtestResults;
|
||||
|
||||
public:
|
||||
const QList<QPair<QString, bool>>& getCollectedTestResults() const;
|
||||
void recordResult(const QString& name, bool passed);
|
||||
void setFastFileDirectory(const QString aFastFileDir);
|
||||
QString getFastFileDirectory();
|
||||
|
||||
void setZoneFileDirectory(const QString aZoneFileDir);
|
||||
QString getZoneFileDirectory();
|
||||
|
||||
void createDirectory(const QString aDir);
|
||||
QStringList findZoneFiles(const QString &aBaseDir, int aMaxIter = FILE_MAX);
|
||||
|
||||
QStringList findFastFiles(const QString &aBaseDir, int aMaxIter = FILE_MAX);
|
||||
|
||||
virtual void initTestCase() = 0;
|
||||
|
||||
void testDecompression_data();
|
||||
virtual void testDecompression() = 0;
|
||||
|
||||
void testCompression_data();
|
||||
virtual void testCompression() = 0;
|
||||
|
||||
void testFactory_data();
|
||||
virtual void testFactory() = 0;
|
||||
|
||||
virtual void cleanupTestCase() = 0;
|
||||
|
||||
private:
|
||||
QString mFastFileDirectory;
|
||||
QString mZoneFileDirectory;
|
||||
};
|
||||
|
||||
#endif // AUTOTEST_COD_CPP
|
||||
@ -1,11 +0,0 @@
|
||||
#include "autotest_xplor.h"
|
||||
|
||||
void AutoTest_XPlor::initTestCase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AutoTest_XPlor::cleanupTestCase()
|
||||
{
|
||||
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
#ifndef AUTOTEST_XPLOR_H
|
||||
#define AUTOTEST_XPLOR_H
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
class AutoTest_XPlor : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
private slots:
|
||||
};
|
||||
|
||||
#endif // AUTOTEST_XPLOR_H
|
||||
194
tests/data.qrc
194
tests/data.qrc
@ -1,194 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/cod5/zonefile">
|
||||
<file alias="ber1.zone">data/cod5/zonefile/ber1.zone</file>
|
||||
<file alias="ber1_load.zone">data/cod5/zonefile/ber1_load.zone</file>
|
||||
<file alias="ber2.zone">data/cod5/zonefile/ber2.zone</file>
|
||||
<file alias="ber2_load.zone">data/cod5/zonefile/ber2_load.zone</file>
|
||||
<file alias="ber3.zone">data/cod5/zonefile/ber3.zone</file>
|
||||
<file alias="ber3_load.zone">data/cod5/zonefile/ber3_load.zone</file>
|
||||
<file alias="ber3b.zone">data/cod5/zonefile/ber3b.zone</file>
|
||||
<file alias="ber3b_load.zone">data/cod5/zonefile/ber3b_load.zone</file>
|
||||
<file alias="code_post_gfx_mp.zone">data/cod5/zonefile/code_post_gfx_mp.zone</file>
|
||||
<file alias="common_ignore.zone">data/cod5/zonefile/common_ignore.zone</file>
|
||||
<file alias="default.zone">data/cod5/zonefile/default.zone</file>
|
||||
<file alias="localized_mp_asylum.zone">data/cod5/zonefile/localized_mp_asylum.zone</file>
|
||||
<file alias="localized_mp_castle.zone">data/cod5/zonefile/localized_mp_castle.zone</file>
|
||||
<file alias="localized_mp_kneedeep.zone">data/cod5/zonefile/localized_mp_kneedeep.zone</file>
|
||||
<file alias="mak.zone">data/cod5/zonefile/mak.zone</file>
|
||||
<file alias="mak_load.zone">data/cod5/zonefile/mak_load.zone</file>
|
||||
<file alias="mp_airfield_load.zone">data/cod5/zonefile/mp_airfield_load.zone</file>
|
||||
<file alias="mp_asylum.zone">data/cod5/zonefile/mp_asylum.zone</file>
|
||||
<file alias="mp_asylum_load.zone">data/cod5/zonefile/mp_asylum_load.zone</file>
|
||||
<file alias="mp_bgate.zone">data/cod5/zonefile/mp_bgate.zone</file>
|
||||
<file alias="mp_bgate_load.zone">data/cod5/zonefile/mp_bgate_load.zone</file>
|
||||
<file alias="mp_castle_load.zone">data/cod5/zonefile/mp_castle_load.zone</file>
|
||||
<file alias="mp_courtyard_load.zone">data/cod5/zonefile/mp_courtyard_load.zone</file>
|
||||
<file alias="mp_docks.zone">data/cod5/zonefile/mp_docks.zone</file>
|
||||
<file alias="mp_docks_load.zone">data/cod5/zonefile/mp_docks_load.zone</file>
|
||||
<file alias="mp_dome_load.zone">data/cod5/zonefile/mp_dome_load.zone</file>
|
||||
<file alias="mp_downfall.zone">data/cod5/zonefile/mp_downfall.zone</file>
|
||||
<file alias="mp_downfall_load.zone">data/cod5/zonefile/mp_downfall_load.zone</file>
|
||||
<file alias="mp_drum_load.zone">data/cod5/zonefile/mp_drum_load.zone</file>
|
||||
<file alias="mp_hangar.zone">data/cod5/zonefile/mp_hangar.zone</file>
|
||||
<file alias="mp_hangar_load.zone">data/cod5/zonefile/mp_hangar_load.zone</file>
|
||||
<file alias="mp_kneedeep.zone">data/cod5/zonefile/mp_kneedeep.zone</file>
|
||||
<file alias="mp_kneedeep_load.zone">data/cod5/zonefile/mp_kneedeep_load.zone</file>
|
||||
<file alias="mp_kwai.zone">data/cod5/zonefile/mp_kwai.zone</file>
|
||||
<file alias="mp_kwai_load.zone">data/cod5/zonefile/mp_kwai_load.zone</file>
|
||||
<file alias="mp_makin.zone">data/cod5/zonefile/mp_makin.zone</file>
|
||||
<file alias="mp_makin_day.zone">data/cod5/zonefile/mp_makin_day.zone</file>
|
||||
<file alias="mp_makin_day_load.zone">data/cod5/zonefile/mp_makin_day_load.zone</file>
|
||||
<file alias="mp_makin_load.zone">data/cod5/zonefile/mp_makin_load.zone</file>
|
||||
<file alias="mp_nachtfeuer.zone">data/cod5/zonefile/mp_nachtfeuer.zone</file>
|
||||
<file alias="mp_nachtfeuer_load.zone">data/cod5/zonefile/mp_nachtfeuer_load.zone</file>
|
||||
<file alias="mp_outskirts.zone">data/cod5/zonefile/mp_outskirts.zone</file>
|
||||
<file alias="mp_outskirts_load.zone">data/cod5/zonefile/mp_outskirts_load.zone</file>
|
||||
<file alias="mp_roundhouse.zone">data/cod5/zonefile/mp_roundhouse.zone</file>
|
||||
<file alias="mp_roundhouse_load.zone">data/cod5/zonefile/mp_roundhouse_load.zone</file>
|
||||
<file alias="mp_seelow.zone">data/cod5/zonefile/mp_seelow.zone</file>
|
||||
<file alias="mp_seelow_load.zone">data/cod5/zonefile/mp_seelow_load.zone</file>
|
||||
<file alias="mp_shrine.zone">data/cod5/zonefile/mp_shrine.zone</file>
|
||||
<file alias="mp_shrine_load.zone">data/cod5/zonefile/mp_shrine_load.zone</file>
|
||||
<file alias="mp_stalingrad.zone">data/cod5/zonefile/mp_stalingrad.zone</file>
|
||||
<file alias="mp_stalingrad_load.zone">data/cod5/zonefile/mp_stalingrad_load.zone</file>
|
||||
<file alias="mp_suburban.zone">data/cod5/zonefile/mp_suburban.zone</file>
|
||||
<file alias="mp_suburban_load.zone">data/cod5/zonefile/mp_suburban_load.zone</file>
|
||||
<file alias="mp_subway.zone">data/cod5/zonefile/mp_subway.zone</file>
|
||||
<file alias="mp_subway_load.zone">data/cod5/zonefile/mp_subway_load.zone</file>
|
||||
<file alias="mp_vodka.zone">data/cod5/zonefile/mp_vodka.zone</file>
|
||||
<file alias="mp_vodka_load.zone">data/cod5/zonefile/mp_vodka_load.zone</file>
|
||||
<file alias="nazi_zombie_asylum.zone">data/cod5/zonefile/nazi_zombie_asylum.zone</file>
|
||||
<file alias="nazi_zombie_asylum_load.zone">data/cod5/zonefile/nazi_zombie_asylum_load.zone</file>
|
||||
<file alias="nazi_zombie_asylum_patch.zone">data/cod5/zonefile/nazi_zombie_asylum_patch.zone</file>
|
||||
<file alias="nazi_zombie_factory.zone">data/cod5/zonefile/nazi_zombie_factory.zone</file>
|
||||
<file alias="nazi_zombie_factory_load.zone">data/cod5/zonefile/nazi_zombie_factory_load.zone</file>
|
||||
<file alias="nazi_zombie_factory_patch.zone">data/cod5/zonefile/nazi_zombie_factory_patch.zone</file>
|
||||
<file alias="nazi_zombie_prototype.zone">data/cod5/zonefile/nazi_zombie_prototype.zone</file>
|
||||
<file alias="nazi_zombie_prototype_load.zone">data/cod5/zonefile/nazi_zombie_prototype_load.zone</file>
|
||||
<file alias="nazi_zombie_sumpf.zone">data/cod5/zonefile/nazi_zombie_sumpf.zone</file>
|
||||
<file alias="nazi_zombie_sumpf_load.zone">data/cod5/zonefile/nazi_zombie_sumpf_load.zone</file>
|
||||
<file alias="nazi_zombie_sumpf_patch.zone">data/cod5/zonefile/nazi_zombie_sumpf_patch.zone</file>
|
||||
<file alias="oki2.zone">data/cod5/zonefile/oki2.zone</file>
|
||||
<file alias="oki2_load.zone">data/cod5/zonefile/oki2_load.zone</file>
|
||||
<file alias="oki3.zone">data/cod5/zonefile/oki3.zone</file>
|
||||
<file alias="oki3_load.zone">data/cod5/zonefile/oki3_load.zone</file>
|
||||
<file alias="outro.zone">data/cod5/zonefile/outro.zone</file>
|
||||
<file alias="patch.zone">data/cod5/zonefile/patch.zone</file>
|
||||
<file alias="patch_mp.zone">data/cod5/zonefile/patch_mp.zone</file>
|
||||
<file alias="pby_fly.zone">data/cod5/zonefile/pby_fly.zone</file>
|
||||
<file alias="pby_fly_load.zone">data/cod5/zonefile/pby_fly_load.zone</file>
|
||||
<file alias="pel1.zone">data/cod5/zonefile/pel1.zone</file>
|
||||
<file alias="pel1_load.zone">data/cod5/zonefile/pel1_load.zone</file>
|
||||
<file alias="pel1a.zone">data/cod5/zonefile/pel1a.zone</file>
|
||||
<file alias="pel1a_load.zone">data/cod5/zonefile/pel1a_load.zone</file>
|
||||
<file alias="pel1b.zone">data/cod5/zonefile/pel1b.zone</file>
|
||||
<file alias="pel1b_load.zone">data/cod5/zonefile/pel1b_load.zone</file>
|
||||
<file alias="pel2.zone">data/cod5/zonefile/pel2.zone</file>
|
||||
<file alias="pel2_load.zone">data/cod5/zonefile/pel2_load.zone</file>
|
||||
<file alias="see1.zone">data/cod5/zonefile/see1.zone</file>
|
||||
<file alias="see1_load.zone">data/cod5/zonefile/see1_load.zone</file>
|
||||
<file alias="see2.zone">data/cod5/zonefile/see2.zone</file>
|
||||
<file alias="see2_load.zone">data/cod5/zonefile/see2_load.zone</file>
|
||||
<file alias="sniper.zone">data/cod5/zonefile/sniper.zone</file>
|
||||
<file alias="sniper_load.zone">data/cod5/zonefile/sniper_load.zone</file>
|
||||
<file alias="ui.zone">data/cod5/zonefile/ui.zone</file>
|
||||
<file alias="ui_mp.zone">data/cod5/zonefile/ui_mp.zone</file>
|
||||
<file alias="xcommon_rtx.zone">data/cod5/zonefile/xcommon_rtx.zone</file>
|
||||
</qresource>
|
||||
<qresource prefix="/cod5/fastfile">
|
||||
<file alias="ber1.ff">data/cod5/fastfile/ber1.ff</file>
|
||||
<file alias="ber1_load.ff">data/cod5/fastfile/ber1_load.ff</file>
|
||||
<file alias="ber2.ff">data/cod5/fastfile/ber2.ff</file>
|
||||
<file alias="ber2_load.ff">data/cod5/fastfile/ber2_load.ff</file>
|
||||
<file alias="ber3.ff">data/cod5/fastfile/ber3.ff</file>
|
||||
<file alias="ber3_load.ff">data/cod5/fastfile/ber3_load.ff</file>
|
||||
<file alias="ber3b.ff">data/cod5/fastfile/ber3b.ff</file>
|
||||
<file alias="ber3b_load.ff">data/cod5/fastfile/ber3b_load.ff</file>
|
||||
<file alias="code_post_gfx_mp.ff">data/cod5/fastfile/code_post_gfx_mp.ff</file>
|
||||
<file alias="common_ignore.ff">data/cod5/fastfile/common_ignore.ff</file>
|
||||
<file alias="default.ff">data/cod5/fastfile/default.ff</file>
|
||||
<file alias="localized_mp_asylum.ff">data/cod5/fastfile/localized_mp_asylum.ff</file>
|
||||
<file alias="localized_mp_castle.ff">data/cod5/fastfile/localized_mp_castle.ff</file>
|
||||
<file alias="localized_mp_kneedeep.ff">data/cod5/fastfile/localized_mp_kneedeep.ff</file>
|
||||
<file alias="mak.ff">data/cod5/fastfile/mak.ff</file>
|
||||
<file alias="mak_load.ff">data/cod5/fastfile/mak_load.ff</file>
|
||||
<file alias="mp_airfield_load.ff">data/cod5/fastfile/mp_airfield_load.ff</file>
|
||||
<file alias="mp_asylum.ff">data/cod5/fastfile/mp_asylum.ff</file>
|
||||
<file alias="mp_asylum_load.ff">data/cod5/fastfile/mp_asylum_load.ff</file>
|
||||
<file alias="mp_bgate.ff">data/cod5/fastfile/mp_bgate.ff</file>
|
||||
<file alias="mp_bgate_load.ff">data/cod5/fastfile/mp_bgate_load.ff</file>
|
||||
<file alias="mp_castle_load.ff">data/cod5/fastfile/mp_castle_load.ff</file>
|
||||
<file alias="mp_courtyard_load.ff">data/cod5/fastfile/mp_courtyard_load.ff</file>
|
||||
<file alias="mp_docks.ff">data/cod5/fastfile/mp_docks.ff</file>
|
||||
<file alias="mp_docks_load.ff">data/cod5/fastfile/mp_docks_load.ff</file>
|
||||
<file alias="mp_dome_load.ff">data/cod5/fastfile/mp_dome_load.ff</file>
|
||||
<file alias="mp_downfall.ff">data/cod5/fastfile/mp_downfall.ff</file>
|
||||
<file alias="mp_downfall_load.ff">data/cod5/fastfile/mp_downfall_load.ff</file>
|
||||
<file alias="mp_drum_load.ff">data/cod5/fastfile/mp_drum_load.ff</file>
|
||||
<file alias="mp_hangar.ff">data/cod5/fastfile/mp_hangar.ff</file>
|
||||
<file alias="mp_hangar_load.ff">data/cod5/fastfile/mp_hangar_load.ff</file>
|
||||
<file alias="mp_kneedeep.ff">data/cod5/fastfile/mp_kneedeep.ff</file>
|
||||
<file alias="mp_kneedeep_load.ff">data/cod5/fastfile/mp_kneedeep_load.ff</file>
|
||||
<file alias="mp_kwai.ff">data/cod5/fastfile/mp_kwai.ff</file>
|
||||
<file alias="mp_kwai_load.ff">data/cod5/fastfile/mp_kwai_load.ff</file>
|
||||
<file alias="mp_makin.ff">data/cod5/fastfile/mp_makin.ff</file>
|
||||
<file alias="mp_makin_day.ff">data/cod5/fastfile/mp_makin_day.ff</file>
|
||||
<file alias="mp_makin_day_load.ff">data/cod5/fastfile/mp_makin_day_load.ff</file>
|
||||
<file alias="mp_makin_load.ff">data/cod5/fastfile/mp_makin_load.ff</file>
|
||||
<file alias="mp_nachtfeuer.ff">data/cod5/fastfile/mp_nachtfeuer.ff</file>
|
||||
<file alias="mp_nachtfeuer_load.ff">data/cod5/fastfile/mp_nachtfeuer_load.ff</file>
|
||||
<file alias="mp_outskirts.ff">data/cod5/fastfile/mp_outskirts.ff</file>
|
||||
<file alias="mp_outskirts_load.ff">data/cod5/fastfile/mp_outskirts_load.ff</file>
|
||||
<file alias="mp_roundhouse.ff">data/cod5/fastfile/mp_roundhouse.ff</file>
|
||||
<file alias="mp_roundhouse_load.ff">data/cod5/fastfile/mp_roundhouse_load.ff</file>
|
||||
<file alias="mp_seelow.ff">data/cod5/fastfile/mp_seelow.ff</file>
|
||||
<file alias="mp_seelow_load.ff">data/cod5/fastfile/mp_seelow_load.ff</file>
|
||||
<file alias="mp_shrine.ff">data/cod5/fastfile/mp_shrine.ff</file>
|
||||
<file alias="mp_shrine_load.ff">data/cod5/fastfile/mp_shrine_load.ff</file>
|
||||
<file alias="mp_stalingrad.ff">data/cod5/fastfile/mp_stalingrad.ff</file>
|
||||
<file alias="mp_stalingrad_load.ff">data/cod5/fastfile/mp_stalingrad_load.ff</file>
|
||||
<file alias="mp_suburban.ff">data/cod5/fastfile/mp_suburban.ff</file>
|
||||
<file alias="mp_suburban_load.ff">data/cod5/fastfile/mp_suburban_load.ff</file>
|
||||
<file alias="mp_subway.ff">data/cod5/fastfile/mp_subway.ff</file>
|
||||
<file alias="mp_subway_load.ff">data/cod5/fastfile/mp_subway_load.ff</file>
|
||||
<file alias="mp_vodka.ff">data/cod5/fastfile/mp_vodka.ff</file>
|
||||
<file alias="mp_vodka_load.ff">data/cod5/fastfile/mp_vodka_load.ff</file>
|
||||
<file alias="nazi_zombie_asylum.ff">data/cod5/fastfile/nazi_zombie_asylum.ff</file>
|
||||
<file alias="nazi_zombie_asylum_load.ff">data/cod5/fastfile/nazi_zombie_asylum_load.ff</file>
|
||||
<file alias="nazi_zombie_asylum_patch.ff">data/cod5/fastfile/nazi_zombie_asylum_patch.ff</file>
|
||||
<file alias="nazi_zombie_factory.ff">data/cod5/fastfile/nazi_zombie_factory.ff</file>
|
||||
<file alias="nazi_zombie_factory_load.ff">data/cod5/fastfile/nazi_zombie_factory_load.ff</file>
|
||||
<file alias="nazi_zombie_factory_patch.ff">data/cod5/fastfile/nazi_zombie_factory_patch.ff</file>
|
||||
<file alias="nazi_zombie_prototype.ff">data/cod5/fastfile/nazi_zombie_prototype.ff</file>
|
||||
<file alias="nazi_zombie_prototype_load.ff">data/cod5/fastfile/nazi_zombie_prototype_load.ff</file>
|
||||
<file alias="nazi_zombie_sumpf.ff">data/cod5/fastfile/nazi_zombie_sumpf.ff</file>
|
||||
<file alias="nazi_zombie_sumpf_load.ff">data/cod5/fastfile/nazi_zombie_sumpf_load.ff</file>
|
||||
<file alias="nazi_zombie_sumpf_patch.ff">data/cod5/fastfile/nazi_zombie_sumpf_patch.ff</file>
|
||||
<file alias="oki2.ff">data/cod5/fastfile/oki2.ff</file>
|
||||
<file alias="oki2_load.ff">data/cod5/fastfile/oki2_load.ff</file>
|
||||
<file alias="oki3.ff">data/cod5/fastfile/oki3.ff</file>
|
||||
<file alias="oki3_load.ff">data/cod5/fastfile/oki3_load.ff</file>
|
||||
<file alias="outro.ff">data/cod5/fastfile/outro.ff</file>
|
||||
<file alias="patch.ff">data/cod5/fastfile/patch.ff</file>
|
||||
<file alias="patch_mp.ff">data/cod5/fastfile/patch_mp.ff</file>
|
||||
<file alias="pby_fly.ff">data/cod5/fastfile/pby_fly.ff</file>
|
||||
<file alias="pby_fly_load.ff">data/cod5/fastfile/pby_fly_load.ff</file>
|
||||
<file alias="pel1.ff">data/cod5/fastfile/pel1.ff</file>
|
||||
<file alias="pel1_load.ff">data/cod5/fastfile/pel1_load.ff</file>
|
||||
<file alias="pel1a.ff">data/cod5/fastfile/pel1a.ff</file>
|
||||
<file alias="pel1a_load.ff">data/cod5/fastfile/pel1a_load.ff</file>
|
||||
<file alias="pel1b.ff">data/cod5/fastfile/pel1b.ff</file>
|
||||
<file alias="pel1b_load.ff">data/cod5/fastfile/pel1b_load.ff</file>
|
||||
<file alias="pel2.ff">data/cod5/fastfile/pel2.ff</file>
|
||||
<file alias="pel2_load.ff">data/cod5/fastfile/pel2_load.ff</file>
|
||||
<file alias="see1.ff">data/cod5/fastfile/see1.ff</file>
|
||||
<file alias="see1_load.ff">data/cod5/fastfile/see1_load.ff</file>
|
||||
<file alias="see2.ff">data/cod5/fastfile/see2.ff</file>
|
||||
<file alias="see2_load.ff">data/cod5/fastfile/see2_load.ff</file>
|
||||
<file alias="sniper.ff">data/cod5/fastfile/sniper.ff</file>
|
||||
<file alias="sniper_load.ff">data/cod5/fastfile/sniper_load.ff</file>
|
||||
<file alias="ui.ff">data/cod5/fastfile/ui.ff</file>
|
||||
<file alias="ui_mp.ff">data/cod5/fastfile/ui_mp.ff</file>
|
||||
<file alias="xcommon_rtx.ff">data/cod5/fastfile/xcommon_rtx.ff</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@ -1,463 +0,0 @@
|
||||
#include <QtTest/QtTest>
|
||||
//#include "autotest_xplor.cpp"
|
||||
|
||||
#include "360/autotest_cod2_360.cpp"
|
||||
#include "360/autotest_cod4_360.cpp"
|
||||
#include "360/autotest_cod5_360.cpp"
|
||||
#include "360/autotest_cod6_360.cpp"
|
||||
#include "360/autotest_cod7_360.cpp"
|
||||
#include "360/autotest_cod8_360.cpp"
|
||||
#include "360/autotest_cod9_360.cpp"
|
||||
#include "360/autotest_cod10_360.cpp"
|
||||
#include "360/autotest_cod11_360.cpp"
|
||||
#include "360/autotest_cod12_360.cpp"
|
||||
|
||||
#include "PC/autotest_cod4_pc.cpp"
|
||||
#include "PC/autotest_cod5_pc.cpp"
|
||||
#include "PC/autotest_cod6_pc.cpp"
|
||||
#include "PC/autotest_cod7_pc.cpp"
|
||||
#include "PC/autotest_cod8_pc.cpp"
|
||||
#include "PC/autotest_cod9_pc.cpp"
|
||||
#include "PC/autotest_cod10_pc.cpp"
|
||||
#include "PC/autotest_cod11_pc.cpp"
|
||||
#include "PC/autotest_cod12_pc.cpp"
|
||||
|
||||
#include "PS3/autotest_cod4_ps3.cpp"
|
||||
#include "PS3/autotest_cod5_ps3.cpp"
|
||||
#include "PS3/autotest_cod6_ps3.cpp"
|
||||
#include "PS3/autotest_cod7_ps3.cpp"
|
||||
#include "PS3/autotest_cod8_ps3.cpp"
|
||||
#include "PS3/autotest_cod9_ps3.cpp"
|
||||
#include "PS3/autotest_cod10_ps3.cpp"
|
||||
#include "PS3/autotest_cod11_ps3.cpp"
|
||||
#include "PS3/autotest_cod12_ps3.cpp"
|
||||
|
||||
#include "Wii/autotest_cod4_wii.cpp"
|
||||
#include "Wii/autotest_cod7_wii.cpp"
|
||||
#include "Wii/autotest_cod8_wii.cpp"
|
||||
|
||||
#include "WiiU/autotest_cod9_wiiu.cpp"
|
||||
#include "WiiU/autotest_cod10_wiiu.cpp"
|
||||
|
||||
// clearly named defines for filtering logic
|
||||
#define TEST_EVERYTHING 0
|
||||
|
||||
// Global filters
|
||||
#define TEST_ALL_PLATFORMS 0
|
||||
#define TEST_ALL_COD_GAMES 0
|
||||
|
||||
// individual games
|
||||
#define TEST_COD2 0
|
||||
#define TEST_COD4 1
|
||||
#define TEST_COD5 0
|
||||
#define TEST_COD6 0
|
||||
#define TEST_COD7 0
|
||||
#define TEST_COD8 0
|
||||
#define TEST_COD9 0
|
||||
#define TEST_COD10 0
|
||||
#define TEST_COD11 0
|
||||
#define TEST_COD12 1
|
||||
|
||||
// individual platforms
|
||||
#define TEST_360 0
|
||||
#define TEST_PC 0
|
||||
#define TEST_PS3 0
|
||||
#define TEST_WII 0
|
||||
#define TEST_WIIU 0
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**********************************/
|
||||
/********* XPLOR UI TESTS *********/
|
||||
/**********************************/
|
||||
|
||||
// AutoTest_XPlor test_xplor;
|
||||
// if (!QTest::qExec(&test_xplor, argc, argv)) {
|
||||
// return -1;
|
||||
// }
|
||||
|
||||
/**********************************/
|
||||
/********* 360 COD TESTS *********/
|
||||
/**********************************/
|
||||
|
||||
QVector<AutoTest_COD*> cod2Tests;
|
||||
QVector<AutoTest_COD*> cod4Tests;
|
||||
QVector<AutoTest_COD*> cod5Tests;
|
||||
QVector<AutoTest_COD*> cod6Tests;
|
||||
QVector<AutoTest_COD*> cod7Tests;
|
||||
QVector<AutoTest_COD*> cod8Tests;
|
||||
QVector<AutoTest_COD*> cod9Tests;
|
||||
QVector<AutoTest_COD*> cod10Tests;
|
||||
QVector<AutoTest_COD*> cod11Tests;
|
||||
QVector<AutoTest_COD*> cod12Tests;
|
||||
|
||||
QVector<AutoTest_COD*> xbox360Tests;
|
||||
QVector<AutoTest_COD*> pcTests;
|
||||
QVector<AutoTest_COD*> ps3Tests;
|
||||
QVector<AutoTest_COD*> wiiTests;
|
||||
QVector<AutoTest_COD*> wiiUTests;
|
||||
|
||||
AutoTest_COD2_360 *test_cod2_360 = new AutoTest_COD2_360();
|
||||
test_cod2_360->setFastFileDirectory("G:/Fast Files/360/COD2");
|
||||
test_cod2_360->setZoneFileDirectory("./exports/cod2/360");
|
||||
cod2Tests << test_cod2_360;
|
||||
xbox360Tests << test_cod2_360;
|
||||
|
||||
AutoTest_COD4_360 *test_cod4_360 = new AutoTest_COD4_360();
|
||||
test_cod4_360->setFastFileDirectory("G:/Fast Files/360/COD4");
|
||||
test_cod4_360->setZoneFileDirectory("./exports/cod4/360");
|
||||
cod4Tests << test_cod4_360;
|
||||
xbox360Tests << test_cod4_360;
|
||||
|
||||
AutoTest_COD5_360 *test_cod5_360 = new AutoTest_COD5_360();
|
||||
test_cod5_360->setFastFileDirectory("G:/Fast Files/360/COD5");
|
||||
test_cod5_360->setZoneFileDirectory("./exports/cod5/360");
|
||||
cod5Tests << test_cod5_360;
|
||||
xbox360Tests << test_cod5_360;
|
||||
|
||||
AutoTest_COD6_360 *test_cod6_360 = new AutoTest_COD6_360();
|
||||
test_cod6_360->setFastFileDirectory("G:/Fast Files/360/COD6");
|
||||
test_cod6_360->setZoneFileDirectory("./exports/cod6/360");
|
||||
cod6Tests << test_cod6_360;
|
||||
xbox360Tests << test_cod6_360;
|
||||
|
||||
AutoTest_COD7_360 *test_cod7_360 = new AutoTest_COD7_360();
|
||||
test_cod7_360->setFastFileDirectory("G:/Fast Files/360/COD7");
|
||||
test_cod7_360->setZoneFileDirectory("./exports/cod7/360");
|
||||
cod7Tests << test_cod7_360;
|
||||
xbox360Tests << test_cod7_360;
|
||||
|
||||
AutoTest_COD8_360 *test_cod8_360 = new AutoTest_COD8_360();
|
||||
test_cod8_360->setFastFileDirectory("G:/Fast Files/360/COD8");
|
||||
test_cod8_360->setZoneFileDirectory("./exports/cod8/360");
|
||||
cod8Tests << test_cod8_360;
|
||||
xbox360Tests << test_cod8_360;
|
||||
|
||||
AutoTest_COD9_360 *test_cod9_360 = new AutoTest_COD9_360();
|
||||
test_cod9_360->setFastFileDirectory("G:/Fast Files/360/COD9");
|
||||
test_cod9_360->setZoneFileDirectory("./exports/cod9/360");
|
||||
cod9Tests << test_cod9_360;
|
||||
xbox360Tests << test_cod9_360;
|
||||
|
||||
AutoTest_COD10_360 *test_cod10_360 = new AutoTest_COD10_360();
|
||||
test_cod10_360->setFastFileDirectory("G:/Fast Files/360/COD10");
|
||||
test_cod10_360->setZoneFileDirectory("./exports/cod10/360");
|
||||
cod10Tests << test_cod10_360;
|
||||
xbox360Tests << test_cod10_360;
|
||||
|
||||
AutoTest_COD11_360 *test_cod11_360 = new AutoTest_COD11_360();
|
||||
test_cod11_360->setFastFileDirectory("G:/Fast Files/360/COD11");
|
||||
test_cod11_360->setZoneFileDirectory("./exports/cod11/360");
|
||||
cod11Tests << test_cod11_360;
|
||||
xbox360Tests << test_cod11_360;
|
||||
|
||||
AutoTest_COD12_360 *test_cod12_360 = new AutoTest_COD12_360();
|
||||
test_cod12_360->setFastFileDirectory("G:/Fast Files/360/COD12");
|
||||
test_cod12_360->setZoneFileDirectory("./exports/cod12/360");
|
||||
cod12Tests << test_cod12_360;
|
||||
xbox360Tests << test_cod12_360;
|
||||
|
||||
/**********************************/
|
||||
/********* PC COD TESTS *********/
|
||||
/**********************************/
|
||||
|
||||
AutoTest_COD4_PC *test_cod4_pc = new AutoTest_COD4_PC();
|
||||
test_cod4_pc->setFastFileDirectory("G:/Fast Files/PC/COD4");
|
||||
test_cod4_pc->setZoneFileDirectory("./exports/cod4/PC");
|
||||
cod4Tests << test_cod4_pc;
|
||||
pcTests << test_cod4_pc;
|
||||
|
||||
AutoTest_COD5_PC *test_cod5_pc = new AutoTest_COD5_PC();
|
||||
test_cod5_pc->setFastFileDirectory("G:/Fast Files/PC/COD5");
|
||||
test_cod5_pc->setZoneFileDirectory("./exports/cod5/PC");
|
||||
cod5Tests << test_cod5_pc;
|
||||
pcTests << test_cod5_pc;
|
||||
|
||||
AutoTest_COD6_PC *test_cod6_pc = new AutoTest_COD6_PC();
|
||||
test_cod6_pc->setFastFileDirectory("G:/Fast Files/PC/COD6");
|
||||
test_cod6_pc->setZoneFileDirectory("./exports/cod6/PC");
|
||||
cod6Tests << test_cod6_pc;
|
||||
pcTests << test_cod6_pc;
|
||||
|
||||
AutoTest_COD7_PC *test_cod7_pc = new AutoTest_COD7_PC();
|
||||
test_cod7_pc->setFastFileDirectory("G:/Fast Files/PC/COD7");
|
||||
test_cod7_pc->setZoneFileDirectory("./exports/cod7/PC");
|
||||
cod7Tests << test_cod7_pc;
|
||||
pcTests << test_cod7_pc;
|
||||
|
||||
AutoTest_COD8_PC *test_cod8_pc = new AutoTest_COD8_PC();
|
||||
test_cod8_pc->setFastFileDirectory("G:/Fast Files/PC/COD8");
|
||||
test_cod8_pc->setZoneFileDirectory("./exports/cod8/PC");
|
||||
cod8Tests << test_cod8_pc;
|
||||
pcTests << test_cod8_pc;
|
||||
|
||||
AutoTest_COD9_PC *test_cod9_pc = new AutoTest_COD9_PC();
|
||||
test_cod9_pc->setFastFileDirectory("G:/Fast Files/PC/COD9");
|
||||
test_cod9_pc->setZoneFileDirectory("./exports/cod9/PC");
|
||||
cod9Tests << test_cod9_pc;
|
||||
pcTests << test_cod9_pc;
|
||||
|
||||
AutoTest_COD10_PC *test_cod10_pc = new AutoTest_COD10_PC();
|
||||
test_cod10_pc->setFastFileDirectory("G:/Fast Files/PC/COD10");
|
||||
test_cod10_pc->setZoneFileDirectory("./exports/cod10/PC");
|
||||
cod10Tests << test_cod10_pc;
|
||||
pcTests << test_cod10_pc;
|
||||
|
||||
AutoTest_COD11_PC *test_cod11_pc = new AutoTest_COD11_PC();
|
||||
test_cod11_pc->setFastFileDirectory("G:/Fast Files/PC/COD11");
|
||||
test_cod11_pc->setZoneFileDirectory("./exports/cod11/PC");
|
||||
cod11Tests << test_cod11_pc;
|
||||
pcTests << test_cod11_pc;
|
||||
|
||||
AutoTest_COD12_PC *test_cod12_pc = new AutoTest_COD12_PC();
|
||||
test_cod12_pc->setFastFileDirectory("G:/Fast Files/PC/COD12");
|
||||
test_cod12_pc->setZoneFileDirectory("./exports/cod12/PC");
|
||||
//cod12Tests << test_cod12_pc;
|
||||
pcTests << test_cod12_pc;
|
||||
|
||||
/**********************************/
|
||||
/********* PS3 COD TESTS *********/
|
||||
/**********************************/
|
||||
|
||||
AutoTest_COD4_PS3 *test_cod4_ps3 = new AutoTest_COD4_PS3();
|
||||
test_cod4_ps3->setFastFileDirectory("G:/Fast Files/PS3/COD4");
|
||||
test_cod4_ps3->setZoneFileDirectory("./exports/cod4/PS3");
|
||||
cod4Tests << test_cod4_ps3;
|
||||
ps3Tests << test_cod4_ps3;
|
||||
|
||||
AutoTest_COD5_PS3 *test_cod5_ps3 = new AutoTest_COD5_PS3();
|
||||
test_cod5_ps3->setFastFileDirectory("G:/Fast Files/PS3/COD5");
|
||||
test_cod5_ps3->setZoneFileDirectory("./exports/cod5/PS3");
|
||||
cod5Tests << test_cod5_ps3;
|
||||
ps3Tests << test_cod5_ps3;
|
||||
|
||||
AutoTest_COD6_PS3 *test_cod6_ps3 = new AutoTest_COD6_PS3();
|
||||
test_cod6_ps3->setFastFileDirectory("G:/Fast Files/PS3/COD6");
|
||||
test_cod6_ps3->setZoneFileDirectory("./exports/cod6/PS3");
|
||||
cod6Tests << test_cod6_ps3;
|
||||
ps3Tests << test_cod6_ps3;
|
||||
|
||||
AutoTest_COD7_PS3 *test_cod7_ps3 = new AutoTest_COD7_PS3();
|
||||
test_cod7_ps3->setFastFileDirectory("G:/Fast Files/PS3/COD7");
|
||||
test_cod7_ps3->setZoneFileDirectory("./exports/cod7/PS3");
|
||||
cod7Tests << test_cod7_ps3;
|
||||
ps3Tests << test_cod7_ps3;
|
||||
|
||||
AutoTest_COD8_PS3 *test_cod8_ps3 = new AutoTest_COD8_PS3();
|
||||
test_cod8_ps3->setFastFileDirectory("G:/Fast Files/PS3/COD8");
|
||||
test_cod8_ps3->setZoneFileDirectory("./exports/cod8/PS3");
|
||||
cod8Tests << test_cod8_ps3;
|
||||
ps3Tests << test_cod8_ps3;
|
||||
|
||||
AutoTest_COD9_PS3 *test_cod9_ps3 = new AutoTest_COD9_PS3();
|
||||
test_cod9_ps3->setFastFileDirectory("G:/Fast Files/PS3/COD9");
|
||||
test_cod9_ps3->setZoneFileDirectory("./exports/cod9/PS3");
|
||||
cod9Tests << test_cod9_ps3;
|
||||
ps3Tests << test_cod9_ps3;
|
||||
|
||||
AutoTest_COD10_PS3 *test_cod10_ps3 = new AutoTest_COD10_PS3();
|
||||
test_cod10_ps3->setFastFileDirectory("G:/Fast Files/PS3/COD10");
|
||||
test_cod10_ps3->setZoneFileDirectory("./exports/cod10/PS3");
|
||||
cod10Tests << test_cod10_ps3;
|
||||
ps3Tests << test_cod10_ps3;
|
||||
|
||||
AutoTest_COD11_PS3 *test_cod11_ps3 = new AutoTest_COD11_PS3();
|
||||
test_cod11_ps3->setFastFileDirectory("G:/Fast Files/PS3/COD11");
|
||||
test_cod11_ps3->setZoneFileDirectory("./exports/cod11/PS3");
|
||||
cod11Tests << test_cod11_ps3;
|
||||
ps3Tests << test_cod11_ps3;
|
||||
|
||||
AutoTest_COD12_PS3 *test_cod12_ps3 = new AutoTest_COD12_PS3();
|
||||
test_cod12_ps3->setFastFileDirectory("G:/Fast Files/PS3/COD12");
|
||||
test_cod12_ps3->setZoneFileDirectory("./exports/cod12/PS3");
|
||||
//cod12Tests << test_cod12_ps3;
|
||||
ps3Tests << test_cod12_ps3;
|
||||
|
||||
/**********************************/
|
||||
/********* Wii COD TESTS *********/
|
||||
/**********************************/
|
||||
|
||||
AutoTest_COD4_Wii *test_cod4_wii = new AutoTest_COD4_Wii();
|
||||
test_cod4_wii->setFastFileDirectory("G:/Fast Files/Wii/COD4");
|
||||
test_cod4_wii->setZoneFileDirectory("./exports/cod4/Wii");
|
||||
cod4Tests << test_cod4_wii;
|
||||
wiiTests << test_cod4_wii;
|
||||
|
||||
AutoTest_COD7_Wii *test_cod7_wii = new AutoTest_COD7_Wii();
|
||||
test_cod7_wii->setFastFileDirectory("G:/Fast Files/Wii/COD7");
|
||||
test_cod7_wii->setZoneFileDirectory("./exports/cod7/Wii");
|
||||
cod7Tests << test_cod7_wii;
|
||||
wiiTests << test_cod7_wii;
|
||||
|
||||
AutoTest_COD8_Wii *test_cod8_wii = new AutoTest_COD8_Wii();
|
||||
test_cod8_wii->setFastFileDirectory("G:/Fast Files/Wii/COD8");
|
||||
test_cod8_wii->setZoneFileDirectory("./exports/cod8/Wii");
|
||||
cod8Tests << test_cod8_wii;
|
||||
wiiTests << test_cod8_wii;
|
||||
|
||||
/**********************************/
|
||||
/********* WiiU COD TESTS *********/
|
||||
/**********************************/
|
||||
|
||||
AutoTest_COD9_WiiU *test_cod9_wiiu = new AutoTest_COD9_WiiU();
|
||||
test_cod9_wiiu->setFastFileDirectory("G:/Fast Files/WiiU/COD9");
|
||||
test_cod9_wiiu->setZoneFileDirectory("./exports/cod9/WiiU");
|
||||
cod9Tests << test_cod9_wiiu;
|
||||
wiiUTests << test_cod9_wiiu;
|
||||
|
||||
AutoTest_COD10_WiiU *test_cod10_wiiu = new AutoTest_COD10_WiiU();
|
||||
test_cod10_wiiu->setFastFileDirectory("G:/Fast Files/WiiU/COD10");
|
||||
test_cod10_wiiu->setZoneFileDirectory("./exports/cod10/PS3");
|
||||
cod10Tests << test_cod10_wiiu;
|
||||
wiiUTests << test_cod10_wiiu;
|
||||
|
||||
QList<QPair<QString, QList<QPair<QString, bool>>>> allResults;
|
||||
|
||||
if (TEST_EVERYTHING || TEST_ALL_COD_GAMES || TEST_COD2) {
|
||||
qDebug() << "-- RUNNING TEST_COD2 --";
|
||||
foreach (auto test, cod2Tests) {
|
||||
QTest::qExec(test, argc, argv);
|
||||
allResults.append({ test->metaObject()->className(), test->getCollectedTestResults() });
|
||||
}
|
||||
}
|
||||
if (TEST_EVERYTHING || TEST_ALL_COD_GAMES || TEST_COD4) {
|
||||
qDebug() << "-- RUNNING TEST_COD4 --";
|
||||
foreach (auto test, cod4Tests) {
|
||||
QTest::qExec(test, argc, argv);
|
||||
allResults.append({ test->metaObject()->className(), test->getCollectedTestResults() });
|
||||
}
|
||||
}
|
||||
if (TEST_EVERYTHING || TEST_ALL_COD_GAMES || TEST_COD5) {
|
||||
qDebug() << "-- RUNNING TEST_COD5 --";
|
||||
foreach (auto test, cod5Tests) {
|
||||
QTest::qExec(test, argc, argv);
|
||||
allResults.append({ test->metaObject()->className(), test->getCollectedTestResults() });
|
||||
}
|
||||
}
|
||||
if (TEST_EVERYTHING || TEST_ALL_COD_GAMES || TEST_COD6) {
|
||||
qDebug() << "-- RUNNING TEST_COD6 --";
|
||||
foreach (auto test, cod6Tests) {
|
||||
QTest::qExec(test, argc, argv);
|
||||
allResults.append({ test->metaObject()->className(), test->getCollectedTestResults() });
|
||||
}
|
||||
}
|
||||
if (TEST_EVERYTHING || TEST_ALL_COD_GAMES || TEST_COD7) {
|
||||
qDebug() << "-- RUNNING TEST_COD7 --";
|
||||
foreach (auto test, cod7Tests) {
|
||||
QTest::qExec(test, argc, argv);
|
||||
allResults.append({ test->metaObject()->className(), test->getCollectedTestResults() });
|
||||
}
|
||||
}
|
||||
if (TEST_EVERYTHING || TEST_ALL_COD_GAMES || TEST_COD8) {
|
||||
qDebug() << "-- RUNNING TEST_COD8 --";
|
||||
foreach (auto test, cod8Tests) {
|
||||
QTest::qExec(test, argc, argv);
|
||||
allResults.append({ test->metaObject()->className(), test->getCollectedTestResults() });
|
||||
}
|
||||
}
|
||||
if (TEST_EVERYTHING || TEST_ALL_COD_GAMES || TEST_COD9) {
|
||||
qDebug() << "-- RUNNING TEST_COD9 --";
|
||||
foreach (auto test, cod9Tests) {
|
||||
QTest::qExec(test, argc, argv);
|
||||
allResults.append({ test->metaObject()->className(), test->getCollectedTestResults() });
|
||||
}
|
||||
}
|
||||
if (TEST_EVERYTHING || TEST_ALL_COD_GAMES || TEST_COD10) {
|
||||
qDebug() << "-- RUNNING TEST_COD10 --";
|
||||
foreach (auto test, cod10Tests) {
|
||||
QTest::qExec(test, argc, argv);
|
||||
allResults.append({ test->metaObject()->className(), test->getCollectedTestResults() });
|
||||
}
|
||||
}
|
||||
if (TEST_EVERYTHING || TEST_ALL_COD_GAMES || TEST_COD11) {
|
||||
qDebug() << "-- RUNNING TEST_COD11 --";
|
||||
foreach (auto test, cod11Tests) {
|
||||
QTest::qExec(test, argc, argv);
|
||||
allResults.append({ test->metaObject()->className(), test->getCollectedTestResults() });
|
||||
}
|
||||
}
|
||||
if (TEST_EVERYTHING || TEST_ALL_COD_GAMES || TEST_COD12) {
|
||||
qDebug() << "-- RUNNING TEST_COD12 --";
|
||||
foreach (auto test, cod12Tests) {
|
||||
QTest::qExec(test, argc, argv);
|
||||
allResults.append({ test->metaObject()->className(), test->getCollectedTestResults() });
|
||||
}
|
||||
}
|
||||
|
||||
if (TEST_EVERYTHING || TEST_ALL_PLATFORMS || TEST_360) {
|
||||
qDebug() << "-- RUNNING TEST_360 --";
|
||||
foreach (auto test, xbox360Tests) {
|
||||
QTest::qExec(test, argc, argv);
|
||||
allResults.append({ test->metaObject()->className(), test->getCollectedTestResults() });
|
||||
}
|
||||
}
|
||||
if (TEST_EVERYTHING || TEST_ALL_PLATFORMS || TEST_PC) {
|
||||
qDebug() << "-- RUNNING TEST_PC --";
|
||||
foreach (auto test, pcTests) {
|
||||
QTest::qExec(test, argc, argv);
|
||||
allResults.append({ test->metaObject()->className(), test->getCollectedTestResults() });
|
||||
}
|
||||
}
|
||||
if (TEST_EVERYTHING || TEST_ALL_PLATFORMS || TEST_PS3) {
|
||||
qDebug() << "-- RUNNING TEST_PS3 --";
|
||||
foreach (auto test, ps3Tests) {
|
||||
QTest::qExec(test, argc, argv);
|
||||
allResults.append({ test->metaObject()->className(), test->getCollectedTestResults() });
|
||||
}
|
||||
}
|
||||
if (TEST_EVERYTHING || TEST_ALL_PLATFORMS || TEST_WII) {
|
||||
qDebug() << "-- RUNNING TEST_WII --";
|
||||
foreach (auto test, wiiTests) {
|
||||
QTest::qExec(test, argc, argv);
|
||||
allResults.append({ test->metaObject()->className(), test->getCollectedTestResults() });
|
||||
}
|
||||
}
|
||||
if (TEST_EVERYTHING || TEST_ALL_PLATFORMS || TEST_WIIU) {
|
||||
qDebug() << "-- RUNNING TEST_WIIU --";
|
||||
foreach (auto test, wiiUTests) {
|
||||
QTest::qExec(test, argc, argv);
|
||||
allResults.append({ test->metaObject()->className(), test->getCollectedTestResults() });
|
||||
}
|
||||
}
|
||||
|
||||
QJsonObject root;
|
||||
root["project"] = "XPlor";
|
||||
root["lastRun"] = QDateTime::currentDateTimeUtc().toString(Qt::ISODate);
|
||||
|
||||
bool allPassed = true;
|
||||
QJsonArray testFiles;
|
||||
|
||||
for (const auto& [className, subtests] : allResults) {
|
||||
QJsonObject fileEntry;
|
||||
fileEntry["name"] = className;
|
||||
|
||||
QJsonArray testArray;
|
||||
bool filePassed = true;
|
||||
|
||||
for (const auto& [testName, passed] : subtests) {
|
||||
testArray.append(QJsonObject{
|
||||
{"name", testName},
|
||||
{"status", passed ? "passed" : "failed"}
|
||||
});
|
||||
if (!passed)
|
||||
filePassed = false;
|
||||
}
|
||||
|
||||
fileEntry["status"] = filePassed ? "passed" : "failed";
|
||||
fileEntry["tests"] = testArray;
|
||||
testFiles.append(fileEntry);
|
||||
|
||||
if (!filePassed)
|
||||
allPassed = false;
|
||||
}
|
||||
|
||||
root["status"] = allPassed ? "passed" : "failed";
|
||||
root["tests"] = testFiles;
|
||||
|
||||
QFile file("G:/FileServer/files/auto_test.json");
|
||||
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||
file.write(QJsonDocument(root).toJson(QJsonDocument::Indented));
|
||||
else
|
||||
qWarning() << "Failed to write JSON output";
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,68 +0,0 @@
|
||||
TEMPLATE = app
|
||||
CONFIG += no_main
|
||||
|
||||
# Enable the testlib module
|
||||
QT += testlib #core-private
|
||||
|
||||
# Define a test-specific flag
|
||||
DEFINES += QT_TESTS
|
||||
|
||||
TARGET = tests
|
||||
|
||||
SOURCES += $$files($$PWD/*.cpp, true)
|
||||
HEADERS += $$files($$PWD/*.h, true)
|
||||
|
||||
# Prevent tests from being built in release mode (optional)
|
||||
# CONFIG(debug, debug|release) {
|
||||
# message("Including test files in Debug mode")
|
||||
# } else {
|
||||
# SOURCES -= autotest_cod5.cpp
|
||||
# }
|
||||
|
||||
LIBS += \
|
||||
-L$$PWD/../third_party/devil_sdk/lib/ -lDevIL -lILU -lILUT \
|
||||
-L$$PWD/../third_party/zlib/lib/ -lzlib \
|
||||
-L$$PWD/../third_party/xbox_sdk/lib -lxcompress64 \
|
||||
-L$$OUT_PWD/../libs/ -lcore \
|
||||
-L$$OUT_PWD/../libs/ -lxassets\
|
||||
-L$$OUT_PWD/../libs/ -lcompression \
|
||||
-L$$OUT_PWD/../libs/ -lencryption \
|
||||
-L$$OUT_PWD/../libs/ -lfastfile \
|
||||
-L$$OUT_PWD/../libs/ -lddsfile \
|
||||
-L$$OUT_PWD/../libs/ -lipakfile \
|
||||
-L$$OUT_PWD/../libs/ -liwifile \
|
||||
-L$$OUT_PWD/../libs/ -lzonefile
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$PWD/../third_party/devil_sdk/include/ \
|
||||
$$PWD/../third_party/zlib/include \
|
||||
$$PWD/../third_party/xbox_sdk/include \
|
||||
$$PWD/../libs/core \
|
||||
$$PWD/../libs/compression \
|
||||
$$PWD/../libs/encryption \
|
||||
$$PWD/../libs/fastfile \
|
||||
$$PWD/../libs/ddsfile \
|
||||
$$PWD/../libs/ipakfile \
|
||||
$$PWD/../libs/iwifile \
|
||||
$$PWD/../libs/xassets \
|
||||
$$PWD/../libs/zonefile
|
||||
|
||||
DEPENDPATH += \
|
||||
$$PWD/../third_party/devil_sdk/include/ \
|
||||
$$PWD/../third_party/zlib/include \
|
||||
$$PWD/../third_party/xbox_sdk/include \
|
||||
$$PWD/../libs/core \
|
||||
$$PWD/../libs/compression \
|
||||
$$PWD/../libs/encryption \
|
||||
$$PWD/../libs/fastfile \
|
||||
$$PWD/../libs/ddsfile \
|
||||
$$PWD/../libs/ipakfile \
|
||||
$$PWD/../libs/iwifile \
|
||||
$$PWD/../libs/xassets \
|
||||
$$PWD/../libs/zonefile
|
||||
|
||||
|
||||
win32 {
|
||||
QMAKE_POST_LINK =
|
||||
QMAKE_POST_LINK += for /D %%G in (\"$$PWD/../third_party/*/lib\") do copy /Y \"%%~G\*.dll\" \"$$OUT_PWD/$$DESTDIR/\" >NUL $$escape_expand(\\n\\t)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user