Autotest changes.
This commit is contained in:
parent
a7904ca74e
commit
c8cfc1c5fc
@ -117,7 +117,7 @@ void AutoTest_COD5_PC::testFactory() {
|
|||||||
|
|
||||||
const QString testName = "Factory ingest: " + fastFilePath;
|
const QString testName = "Factory ingest: " + fastFilePath;
|
||||||
|
|
||||||
std::shared_ptr<FastFile> fastFile = FastFileFactory::Create(fastFilePath, true);
|
std::shared_ptr<FastFile> fastFile = FastFileFactory::Create(fastFilePath);
|
||||||
|
|
||||||
const QString game = fastFile->GetGame();
|
const QString game = fastFile->GetGame();
|
||||||
bool correctGame = game == "COD5";
|
bool correctGame = game == "COD5";
|
||||||
|
|||||||
109
tests/autotest_cod.cpp
Normal file
109
tests/autotest_cod.cpp
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
#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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
#include "fastfile_factory.h"
|
|
||||||
|
|
||||||
#define FILE_MAX 3
|
#define FILE_MAX 3
|
||||||
|
|
||||||
class AutoTest_COD : public QObject {
|
class AutoTest_COD : public QObject {
|
||||||
@ -14,112 +12,28 @@ protected:
|
|||||||
QList<QPair<QString, bool>> m_subtestResults;
|
QList<QPair<QString, bool>> m_subtestResults;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const QList<QPair<QString, bool>>& getCollectedTestResults() const {
|
const QList<QPair<QString, bool>>& getCollectedTestResults() const;
|
||||||
return m_subtestResults;
|
void recordResult(const QString& name, bool passed);
|
||||||
}
|
void setFastFileDirectory(const QString aFastFileDir);
|
||||||
void recordResult(const QString& name, bool passed) {
|
QString getFastFileDirectory();
|
||||||
m_subtestResults.append({ name, passed });
|
|
||||||
}
|
|
||||||
void setFastFileDirectory(const QString aFastFileDir) {
|
|
||||||
mFastFileDirectory = aFastFileDir;
|
|
||||||
}
|
|
||||||
QString getFastFileDirectory() {
|
|
||||||
return mFastFileDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setZoneFileDirectory(const QString aZoneFileDir) {
|
void setZoneFileDirectory(const QString aZoneFileDir);
|
||||||
mZoneFileDirectory = aZoneFileDir;
|
QString getZoneFileDirectory();
|
||||||
}
|
|
||||||
QString getZoneFileDirectory() {
|
|
||||||
return mZoneFileDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
void createDirectory(const QString aDir) {
|
void createDirectory(const QString aDir);
|
||||||
QDir newDir(".");
|
QStringList findZoneFiles(const QString &aBaseDir, int aMaxIter = FILE_MAX);
|
||||||
newDir.mkpath(aDir);
|
|
||||||
}
|
|
||||||
QStringList findZoneFiles(const QString &aBaseDir, int aMaxIter = FILE_MAX) {
|
|
||||||
QList<QPair<qint64, QString>> fileList;
|
|
||||||
|
|
||||||
QDirIterator it(aBaseDir, QStringList() << "*.zone", QDir::Files, QDirIterator::Subdirectories);
|
QStringList findFastFiles(const QString &aBaseDir, int aMaxIter = FILE_MAX);
|
||||||
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 findFastFiles(const QString &aBaseDir, int aMaxIter = FILE_MAX) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void initTestCase() = 0;
|
virtual void initTestCase() = 0;
|
||||||
|
|
||||||
void testDecompression_data() {
|
void 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
virtual void testDecompression() = 0;
|
virtual void testDecompression() = 0;
|
||||||
|
|
||||||
void testCompression_data() {
|
void 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
virtual void testCompression() = 0;
|
virtual void testCompression() = 0;
|
||||||
|
|
||||||
void testFactory_data() {
|
void 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
virtual void testFactory() = 0;
|
virtual void testFactory() = 0;
|
||||||
|
|
||||||
virtual void cleanupTestCase() = 0;
|
virtual void cleanupTestCase() = 0;
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
#include <QtTest/QtTest>
|
#include "autotest_xplor.h"
|
||||||
|
|
||||||
class AutoTest_XPlor : public QObject {
|
void AutoTest_XPlor::initTestCase()
|
||||||
Q_OBJECT
|
{
|
||||||
|
|
||||||
private slots:
|
}
|
||||||
};
|
|
||||||
|
|
||||||
#include "autotest_xplor.moc"
|
void AutoTest_XPlor::cleanupTestCase()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
15
tests/autotest_xplor.h
Normal file
15
tests/autotest_xplor.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#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
|
||||||
Loading…
x
Reference in New Issue
Block a user