Reduce repetitive invocations of QFINDTESTDATA.
Store the file names in variables instead. Task-number: QTBUG-38890 Change-Id: I65f28bb62674f14aa099e935a9d7a4e9e6e90ba9 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
parent
745448d3ea
commit
72024fd50c
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
@ -47,6 +47,9 @@ class tst_QResourceEngine: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
tst_QResourceEngine() : m_runtimeResourceRcc(QFINDTESTDATA("runtime_resource.rcc")) {}
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
@ -59,20 +62,24 @@ private slots:
|
||||
void searchPath();
|
||||
void doubleSlashInRoot();
|
||||
void setLocale();
|
||||
|
||||
private:
|
||||
const QString m_runtimeResourceRcc;
|
||||
};
|
||||
|
||||
|
||||
void tst_QResourceEngine::initTestCase()
|
||||
{
|
||||
QVERIFY(QResource::registerResource(QFINDTESTDATA("runtime_resource.rcc")));
|
||||
QVERIFY(QResource::registerResource(QFINDTESTDATA("runtime_resource.rcc"), "/secondary_root/"));
|
||||
QVERIFY(!m_runtimeResourceRcc.isEmpty());
|
||||
QVERIFY(QResource::registerResource(m_runtimeResourceRcc));
|
||||
QVERIFY(QResource::registerResource(m_runtimeResourceRcc, "/secondary_root/"));
|
||||
}
|
||||
|
||||
void tst_QResourceEngine::cleanupTestCase()
|
||||
{
|
||||
// make sure we don't leak memory
|
||||
QVERIFY(QResource::unregisterResource(QFINDTESTDATA("runtime_resource.rcc")));
|
||||
QVERIFY(QResource::unregisterResource(QFINDTESTDATA("runtime_resource.rcc"), "/secondary_root/"));
|
||||
QVERIFY(QResource::unregisterResource(m_runtimeResourceRcc));
|
||||
QVERIFY(QResource::unregisterResource(m_runtimeResourceRcc, "/secondary_root/"));
|
||||
}
|
||||
|
||||
void tst_QResourceEngine::checkStructure_data()
|
||||
|
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
@ -446,13 +446,15 @@ void tst_QTemporaryFile::rename()
|
||||
void tst_QTemporaryFile::renameFdLeak()
|
||||
{
|
||||
#ifdef Q_OS_UNIX
|
||||
const QByteArray sourceFile = QFile::encodeName(QFINDTESTDATA(__FILE__));
|
||||
QVERIFY(!sourceFile.isEmpty());
|
||||
// Test this on Unix only
|
||||
|
||||
// Open a bunch of files to force the fd count to go up
|
||||
static const int count = 10;
|
||||
int bunch_of_files[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
bunch_of_files[i] = ::open(qPrintable(QFINDTESTDATA("tst_qtemporaryfile.cpp")), O_RDONLY);
|
||||
bunch_of_files[i] = ::open(sourceFile.constData(), O_RDONLY);
|
||||
QVERIFY(bunch_of_files[i] != -1);
|
||||
}
|
||||
|
||||
@ -647,8 +649,10 @@ void tst_QTemporaryFile::createNativeFile_data()
|
||||
QTest::addColumn<bool>("valid");
|
||||
QTest::addColumn<QByteArray>("content");
|
||||
|
||||
QTest::newRow("nativeFile") << QFINDTESTDATA("resources/test.txt") << (qint64)-1 << false << QByteArray();
|
||||
QTest::newRow("nativeFileWithPos") << QFINDTESTDATA("resources/test.txt") << (qint64)5 << false << QByteArray();
|
||||
const QString nativeFilePath = QFINDTESTDATA("resources/test.txt");
|
||||
|
||||
QTest::newRow("nativeFile") << nativeFilePath << (qint64)-1 << false << QByteArray();
|
||||
QTest::newRow("nativeFileWithPos") << nativeFilePath << (qint64)5 << false << QByteArray();
|
||||
QTest::newRow("resourceFile") << ":/resources/test.txt" << (qint64)-1 << true << QByteArray("This is a test");
|
||||
QTest::newRow("resourceFileWithPos") << ":/resources/test.txt" << (qint64)5 << true << QByteArray("This is a test");
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
@ -245,6 +245,8 @@ private:
|
||||
|
||||
QTemporaryDir tempDir;
|
||||
QString testFileName;
|
||||
const QString m_rfc3261FilePath;
|
||||
const QString m_shiftJisFilePath;
|
||||
};
|
||||
|
||||
void runOnExit()
|
||||
@ -256,11 +258,16 @@ Q_DESTRUCTOR_FUNCTION(runOnExit)
|
||||
|
||||
tst_QTextStream::tst_QTextStream()
|
||||
: tempDir(QDir::tempPath() + "/tst_qtextstream.XXXXXX")
|
||||
, m_rfc3261FilePath(QFINDTESTDATA("rfc3261.txt"))
|
||||
, m_shiftJisFilePath(QFINDTESTDATA("shift-jis.txt"))
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QTextStream::initTestCase()
|
||||
{
|
||||
QVERIFY(!m_rfc3261FilePath.isEmpty());
|
||||
QVERIFY(!m_shiftJisFilePath.isEmpty());
|
||||
|
||||
testFileName = tempDir.path() + "/testfile";
|
||||
|
||||
// chdir into the testdata dir and refer to our helper apps with relative paths
|
||||
@ -768,7 +775,7 @@ void tst_QTextStream::generateAllData(bool for_QString)
|
||||
// ------------------------------------------------------------------------------
|
||||
void tst_QTextStream::readLineUntilNull()
|
||||
{
|
||||
QFile file(QFINDTESTDATA("rfc3261.txt"));
|
||||
QFile file(m_rfc3261FilePath);
|
||||
QVERIFY(file.open(QFile::ReadOnly));
|
||||
|
||||
QTextStream stream(&file);
|
||||
@ -887,7 +894,7 @@ void tst_QTextStream::lineCount_data()
|
||||
QTest::newRow("buffersize+1 line") << QByteArray(16384, '\n') << 16384;
|
||||
QTest::newRow("buffersize+2 line") << QByteArray(16385, '\n') << 16385;
|
||||
|
||||
QFile file(QFINDTESTDATA("rfc3261.txt")); file.open(QFile::ReadOnly);
|
||||
QFile file(m_rfc3261FilePath); file.open(QFile::ReadOnly);
|
||||
QTest::newRow("rfc3261") << file.readAll() << 15067;
|
||||
}
|
||||
|
||||
@ -923,7 +930,7 @@ void tst_QTextStream::performance()
|
||||
|
||||
stopWatch.restart();
|
||||
int nlines1 = 0;
|
||||
QFile file(QFINDTESTDATA("rfc3261.txt"));
|
||||
QFile file(m_rfc3261FilePath);
|
||||
QVERIFY(file.open(QFile::ReadOnly));
|
||||
|
||||
while (!file.atEnd()) {
|
||||
@ -935,7 +942,7 @@ void tst_QTextStream::performance()
|
||||
stopWatch.restart();
|
||||
|
||||
int nlines2 = 0;
|
||||
QFile file2(QFINDTESTDATA("rfc3261.txt"));
|
||||
QFile file2(m_rfc3261FilePath);
|
||||
QVERIFY(file2.open(QFile::ReadOnly));
|
||||
|
||||
QTextStream stream(&file2);
|
||||
@ -1155,7 +1162,7 @@ void tst_QTextStream::readNewlines()
|
||||
// ------------------------------------------------------------------------------
|
||||
void tst_QTextStream::seek()
|
||||
{
|
||||
QFile file(QFINDTESTDATA("rfc3261.txt"));
|
||||
QFile file(m_rfc3261FilePath);
|
||||
QVERIFY(file.open(QFile::ReadOnly));
|
||||
|
||||
QTextStream stream(&file);
|
||||
@ -1248,7 +1255,7 @@ void tst_QTextStream::pos()
|
||||
}
|
||||
{
|
||||
// Latin1 device
|
||||
QFile file(QFINDTESTDATA("rfc3261.txt"));
|
||||
QFile file(m_rfc3261FilePath);
|
||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||
|
||||
QTextStream stream(&file);
|
||||
@ -1280,7 +1287,7 @@ void tst_QTextStream::pos()
|
||||
{
|
||||
// Shift-JIS device
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
QFile file(QFINDTESTDATA("shift-jis.txt"));
|
||||
QFile file(m_shiftJisFilePath);
|
||||
if (i == 0)
|
||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||
else
|
||||
|
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
@ -114,7 +114,7 @@ private slots:
|
||||
void uniqueKey();
|
||||
|
||||
protected:
|
||||
QString helperBinary();
|
||||
static QString helperBinary();
|
||||
int remove(const QString &key);
|
||||
|
||||
QString rememberKey(const QString &key)
|
||||
@ -131,10 +131,14 @@ protected:
|
||||
QStringList keys;
|
||||
QList<QSharedMemory*> jail;
|
||||
QSharedMemory *existingSharedMemory;
|
||||
|
||||
private:
|
||||
const QString m_helperBinary;
|
||||
};
|
||||
|
||||
tst_QSharedMemory::tst_QSharedMemory() :
|
||||
existingSharedMemory(0)
|
||||
tst_QSharedMemory::tst_QSharedMemory()
|
||||
: existingSharedMemory(0)
|
||||
, m_helperBinary(tst_QSharedMemory::helperBinary())
|
||||
{
|
||||
}
|
||||
|
||||
@ -144,7 +148,7 @@ tst_QSharedMemory::~tst_QSharedMemory()
|
||||
|
||||
void tst_QSharedMemory::initTestCase()
|
||||
{
|
||||
QVERIFY2(!helperBinary().isEmpty(), "Could not find helper binary");
|
||||
QVERIFY2(!m_helperBinary.isEmpty(), "Could not find helper binary");
|
||||
}
|
||||
|
||||
void tst_QSharedMemory::init()
|
||||
@ -455,7 +459,7 @@ void tst_QSharedMemory::readOnly()
|
||||
rememberKey("readonly_segfault");
|
||||
// ### on windows disable the popup somehow
|
||||
QProcess p;
|
||||
p.start(helperBinary(), QStringList("readonly_segfault"));
|
||||
p.start(m_helperBinary, QStringList("readonly_segfault"));
|
||||
p.setProcessChannelMode(QProcess::ForwardedChannels);
|
||||
p.waitForFinished();
|
||||
QCOMPARE(p.error(), QProcess::Crashed);
|
||||
@ -753,7 +757,7 @@ void tst_QSharedMemory::simpleProcessProducerConsumer()
|
||||
rememberKey("market");
|
||||
|
||||
QProcess producer;
|
||||
producer.start(helperBinary(), QStringList("producer"));
|
||||
producer.start(m_helperBinary, QStringList("producer"));
|
||||
QVERIFY2(producer.waitForStarted(), "Could not start helper binary");
|
||||
QVERIFY2(producer.waitForReadyRead(), "Helper process failed to create shared memory segment: " +
|
||||
producer.readAllStandardError());
|
||||
@ -764,7 +768,7 @@ void tst_QSharedMemory::simpleProcessProducerConsumer()
|
||||
for (int i = 0; i < processes; ++i) {
|
||||
QProcess *p = new QProcess;
|
||||
p->setProcessChannelMode(QProcess::ForwardedChannels);
|
||||
p->start(helperBinary(), consumerArguments);
|
||||
p->start(m_helperBinary, consumerArguments);
|
||||
if (p->waitForStarted(2000))
|
||||
consumers.append(p);
|
||||
else
|
||||
|
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
@ -80,17 +80,20 @@ private slots:
|
||||
#endif // QT_NO_PROCESS
|
||||
|
||||
private:
|
||||
QString helperBinary();
|
||||
static QString helperBinary();
|
||||
QSystemSemaphore *existingLock;
|
||||
|
||||
const QString m_helperBinary;
|
||||
};
|
||||
|
||||
tst_QSystemSemaphore::tst_QSystemSemaphore()
|
||||
: m_helperBinary(helperBinary())
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QSystemSemaphore::initTestCase()
|
||||
{
|
||||
QVERIFY2(!helperBinary().isEmpty(), "Could not find helper binary");
|
||||
QVERIFY2(!m_helperBinary.isEmpty(), "Could not find helper binary");
|
||||
}
|
||||
|
||||
void tst_QSystemSemaphore::init()
|
||||
@ -193,12 +196,12 @@ void tst_QSystemSemaphore::basicProcesses()
|
||||
QProcess release;
|
||||
release.setProcessChannelMode(QProcess::ForwardedChannels);
|
||||
|
||||
acquire.start(helperBinary(), QStringList("acquire"));
|
||||
acquire.start(m_helperBinary, QStringList("acquire"));
|
||||
QVERIFY2(acquire.waitForStarted(), "Could not start helper binary");
|
||||
acquire.waitForFinished(HELPERWAITTIME);
|
||||
QVERIFY(acquire.state() == QProcess::Running);
|
||||
acquire.kill();
|
||||
release.start(helperBinary(), QStringList("release"));
|
||||
release.start(m_helperBinary, QStringList("release"));
|
||||
QVERIFY2(release.waitForStarted(), "Could not start helper binary");
|
||||
acquire.waitForFinished(HELPERWAITTIME);
|
||||
release.waitForFinished(HELPERWAITTIME);
|
||||
@ -227,7 +230,7 @@ void tst_QSystemSemaphore::processes()
|
||||
QProcess *p = new QProcess;
|
||||
p->setProcessChannelMode(QProcess::ForwardedChannels);
|
||||
consumers.append(p);
|
||||
p->start(helperBinary(), QStringList(scripts.at(i)));
|
||||
p->start(m_helperBinary, QStringList(scripts.at(i)));
|
||||
}
|
||||
|
||||
while (!consumers.isEmpty()) {
|
||||
@ -247,14 +250,14 @@ void tst_QSystemSemaphore::undo()
|
||||
QStringList acquireArguments = QStringList("acquire");
|
||||
QProcess acquire;
|
||||
acquire.setProcessChannelMode(QProcess::ForwardedChannels);
|
||||
acquire.start(helperBinary(), acquireArguments);
|
||||
acquire.start(m_helperBinary, acquireArguments);
|
||||
QVERIFY2(acquire.waitForStarted(), "Could not start helper binary");
|
||||
acquire.waitForFinished(HELPERWAITTIME);
|
||||
QVERIFY(acquire.state()== QProcess::NotRunning);
|
||||
|
||||
// At process exit the kernel should auto undo
|
||||
|
||||
acquire.start(helperBinary(), acquireArguments);
|
||||
acquire.start(m_helperBinary, acquireArguments);
|
||||
QVERIFY2(acquire.waitForStarted(), "Could not start helper binary");
|
||||
acquire.waitForFinished(HELPERWAITTIME);
|
||||
QVERIFY(acquire.state()== QProcess::NotRunning);
|
||||
@ -273,18 +276,18 @@ void tst_QSystemSemaphore::initialValue()
|
||||
QProcess release;
|
||||
release.setProcessChannelMode(QProcess::ForwardedChannels);
|
||||
|
||||
acquire.start(helperBinary(), acquireArguments);
|
||||
acquire.start(m_helperBinary, acquireArguments);
|
||||
QVERIFY2(acquire.waitForStarted(), "Could not start helper binary");
|
||||
acquire.waitForFinished(HELPERWAITTIME);
|
||||
QVERIFY(acquire.state()== QProcess::NotRunning);
|
||||
|
||||
acquire.start(helperBinary(), acquireArguments << QLatin1String("2"));
|
||||
acquire.start(m_helperBinary, acquireArguments << QLatin1String("2"));
|
||||
QVERIFY2(acquire.waitForStarted(), "Could not start helper binary");
|
||||
acquire.waitForFinished(HELPERWAITTIME);
|
||||
QVERIFY(acquire.state()== QProcess::Running);
|
||||
acquire.kill();
|
||||
|
||||
release.start(helperBinary(), releaseArguments);
|
||||
release.start(m_helperBinary, releaseArguments);
|
||||
QVERIFY2(release.waitForStarted(), "Could not start helper binary");
|
||||
acquire.waitForFinished(HELPERWAITTIME);
|
||||
release.waitForFinished(HELPERWAITTIME);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
@ -62,6 +62,7 @@ public:
|
||||
tst_QImage();
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void swap();
|
||||
void create();
|
||||
void createInvalidXPM();
|
||||
@ -178,13 +179,21 @@ private slots:
|
||||
void convertToImageFormat();
|
||||
|
||||
void cleanupFunctions();
|
||||
|
||||
private:
|
||||
const QString m_prefix;
|
||||
};
|
||||
|
||||
tst_QImage::tst_QImage()
|
||||
|
||||
: m_prefix(QFINDTESTDATA("images/"))
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QImage::initTestCase()
|
||||
{
|
||||
QVERIFY(!m_prefix.isEmpty());
|
||||
}
|
||||
|
||||
void tst_QImage::swap()
|
||||
{
|
||||
QImage i1( 16, 16, QImage::Format_RGB32 ), i2( 32, 32, QImage::Format_RGB32 );
|
||||
@ -291,21 +300,17 @@ void tst_QImage::formatHandlersInput_data()
|
||||
QTest::addColumn<QString>("testFormat");
|
||||
QTest::addColumn<QString>("testFile");
|
||||
|
||||
const QString prefix = QFINDTESTDATA("images/");
|
||||
if (prefix.isEmpty())
|
||||
QFAIL("can not find images directory!");
|
||||
|
||||
// add a new line here when a file is added
|
||||
QTest::newRow("ICO") << "ICO" << prefix + "image.ico";
|
||||
QTest::newRow("PNG") << "PNG" << prefix + "image.png";
|
||||
QTest::newRow("GIF") << "GIF" << prefix + "image.gif";
|
||||
QTest::newRow("BMP") << "BMP" << prefix + "image.bmp";
|
||||
QTest::newRow("JPEG") << "JPEG" << prefix + "image.jpg";
|
||||
QTest::newRow("PBM") << "PBM" << prefix + "image.pbm";
|
||||
QTest::newRow("PGM") << "PGM" << prefix + "image.pgm";
|
||||
QTest::newRow("PPM") << "PPM" << prefix + "image.ppm";
|
||||
QTest::newRow("XBM") << "XBM" << prefix + "image.xbm";
|
||||
QTest::newRow("XPM") << "XPM" << prefix + "image.xpm";
|
||||
QTest::newRow("ICO") << "ICO" << m_prefix + "image.ico";
|
||||
QTest::newRow("PNG") << "PNG" << m_prefix + "image.png";
|
||||
QTest::newRow("GIF") << "GIF" << m_prefix + "image.gif";
|
||||
QTest::newRow("BMP") << "BMP" << m_prefix + "image.bmp";
|
||||
QTest::newRow("JPEG") << "JPEG" << m_prefix + "image.jpg";
|
||||
QTest::newRow("PBM") << "PBM" << m_prefix + "image.pbm";
|
||||
QTest::newRow("PGM") << "PGM" << m_prefix + "image.pgm";
|
||||
QTest::newRow("PPM") << "PPM" << m_prefix + "image.ppm";
|
||||
QTest::newRow("XBM") << "XBM" << m_prefix + "image.xbm";
|
||||
QTest::newRow("XPM") << "XPM" << m_prefix + "image.xpm";
|
||||
}
|
||||
|
||||
void tst_QImage::formatHandlersInput()
|
||||
@ -1085,10 +1090,7 @@ void tst_QImage::copy()
|
||||
|
||||
void tst_QImage::load()
|
||||
{
|
||||
const QString prefix = QFINDTESTDATA("images/");
|
||||
if (prefix.isEmpty())
|
||||
QFAIL("can not find images directory!");
|
||||
const QString filePath = prefix + QLatin1String("image.jpg");
|
||||
const QString filePath = m_prefix + QLatin1String("image.jpg");
|
||||
|
||||
QImage dest(filePath);
|
||||
QVERIFY(!dest.isNull());
|
||||
@ -1100,10 +1102,7 @@ void tst_QImage::load()
|
||||
|
||||
void tst_QImage::loadFromData()
|
||||
{
|
||||
const QString prefix = QFINDTESTDATA("images/");
|
||||
if (prefix.isEmpty())
|
||||
QFAIL("can not find images directory!");
|
||||
const QString filePath = prefix + QLatin1String("image.jpg");
|
||||
const QString filePath = m_prefix + QLatin1String("image.jpg");
|
||||
|
||||
QImage original(filePath);
|
||||
QVERIFY(!original.isNull());
|
||||
@ -1129,10 +1128,7 @@ void tst_QImage::loadFromData()
|
||||
#if !defined(QT_NO_DATASTREAM)
|
||||
void tst_QImage::loadFromDataStream()
|
||||
{
|
||||
const QString prefix = QFINDTESTDATA("images/");
|
||||
if (prefix.isEmpty())
|
||||
QFAIL("can not find images directory!");
|
||||
const QString filePath = prefix + QLatin1String("image.jpg");
|
||||
const QString filePath = m_prefix + QLatin1String("image.jpg");
|
||||
|
||||
QImage original(filePath);
|
||||
QVERIFY(!original.isNull());
|
||||
|
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
@ -78,6 +78,7 @@ public:
|
||||
public slots:
|
||||
void init();
|
||||
void cleanup();
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
private slots:
|
||||
@ -171,6 +172,11 @@ private slots:
|
||||
void detachOnLoad_QTBUG29639();
|
||||
|
||||
void copyOnNonAlignedBoundary();
|
||||
|
||||
private:
|
||||
const QString m_prefix;
|
||||
const QString m_convertFromImage;
|
||||
const QString m_loadFromData;
|
||||
};
|
||||
|
||||
static bool lenientCompare(const QPixmap &actual, const QPixmap &expected)
|
||||
@ -207,6 +213,9 @@ static bool lenientCompare(const QPixmap &actual, const QPixmap &expected)
|
||||
|
||||
|
||||
tst_QPixmap::tst_QPixmap()
|
||||
: m_prefix(QFINDTESTDATA("images/"))
|
||||
, m_convertFromImage(QFINDTESTDATA("convertFromImage"))
|
||||
, m_loadFromData(QFINDTESTDATA("loadFromData"))
|
||||
{
|
||||
}
|
||||
|
||||
@ -222,6 +231,13 @@ void tst_QPixmap::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void tst_QPixmap::initTestCase()
|
||||
{
|
||||
QVERIFY(!m_prefix.isEmpty());
|
||||
QVERIFY(!m_convertFromImage.isEmpty());
|
||||
QVERIFY(!m_loadFromData.isEmpty());
|
||||
}
|
||||
|
||||
void tst_QPixmap::cleanupTestCase()
|
||||
{
|
||||
QFile::remove(QLatin1String("temp_image.png"));
|
||||
@ -312,22 +328,21 @@ void tst_QPixmap::convertFromImage_data()
|
||||
{
|
||||
QTest::addColumn<QImage>("img1");
|
||||
QTest::addColumn<QImage>("img2");
|
||||
const QString prefix = QFINDTESTDATA("convertFromImage");
|
||||
|
||||
{
|
||||
QImage img1;
|
||||
QImage img2;
|
||||
QVERIFY(img1.load(prefix + "/task31722_0/img1.png"));
|
||||
QVERIFY(img2.load(prefix + "/task31722_0/img2.png"));
|
||||
QVERIFY(img1.load(prefix + "/task31722_0/img1.png"));
|
||||
QVERIFY(img2.load(prefix + "/task31722_0/img2.png"));
|
||||
QVERIFY(img1.load(m_convertFromImage + "/task31722_0/img1.png"));
|
||||
QVERIFY(img2.load(m_convertFromImage + "/task31722_0/img2.png"));
|
||||
QVERIFY(img1.load(m_convertFromImage + "/task31722_0/img1.png"));
|
||||
QVERIFY(img2.load(m_convertFromImage + "/task31722_0/img2.png"));
|
||||
QTest::newRow("Task 31722 0") << img1 << img2;
|
||||
}
|
||||
{
|
||||
QImage img1;
|
||||
QImage img2;
|
||||
QVERIFY(img1.load(prefix + "/task31722_1/img1.png"));
|
||||
QVERIFY(img2.load(prefix + "/task31722_1/img2.png"));
|
||||
QVERIFY(img1.load(m_convertFromImage + "/task31722_1/img1.png"));
|
||||
QVERIFY(img2.load(m_convertFromImage + "/task31722_1/img2.png"));
|
||||
QTest::newRow("Task 31722 1") << img1 << img2;
|
||||
}
|
||||
}
|
||||
@ -346,11 +361,10 @@ void tst_QPixmap::convertFromImage()
|
||||
|
||||
void tst_QPixmap::convertFromImageShouldDetach()
|
||||
{
|
||||
const QString prefix = QFINDTESTDATA("convertFromImage");
|
||||
QImage img1;
|
||||
QImage img2;
|
||||
QVERIFY(img1.load(prefix + "/task31722_0/img1.png"));
|
||||
QVERIFY(img2.load(prefix + "/task31722_0/img2.png"));
|
||||
QVERIFY(img1.load(m_convertFromImage + "/task31722_0/img1.png"));
|
||||
QVERIFY(img2.load(m_convertFromImage + "/task31722_0/img2.png"));
|
||||
QPixmap pix = QPixmap::fromImage(img1);
|
||||
QPixmap pix1 = pix;
|
||||
pix.convertFromImage(img2);
|
||||
@ -1202,10 +1216,7 @@ void tst_QPixmap::transformed2()
|
||||
|
||||
void tst_QPixmap::load()
|
||||
{
|
||||
const QString prefix = QFINDTESTDATA("images/");
|
||||
if (prefix.isEmpty())
|
||||
QFAIL("can not find images directory!");
|
||||
const QString filePath = prefix + QLatin1String("designer.png");
|
||||
const QString filePath = m_prefix + QLatin1String("designer.png");
|
||||
|
||||
QPixmap dest(filePath);
|
||||
QVERIFY(!dest.isNull());
|
||||
@ -1217,10 +1228,7 @@ void tst_QPixmap::load()
|
||||
|
||||
void tst_QPixmap::loadFromData()
|
||||
{
|
||||
const QString prefix = QFINDTESTDATA("images/");
|
||||
if (prefix.isEmpty())
|
||||
QFAIL("can not find images directory!");
|
||||
const QString filePath = prefix + QLatin1String("designer.png");
|
||||
const QString filePath = m_prefix + QLatin1String("designer.png");
|
||||
|
||||
QPixmap original(filePath);
|
||||
QVERIFY(!original.isNull());
|
||||
@ -1246,10 +1254,7 @@ void tst_QPixmap::loadFromData()
|
||||
#if !defined(QT_NO_DATASTREAM)
|
||||
void tst_QPixmap::loadFromDataStream()
|
||||
{
|
||||
const QString prefix = QFINDTESTDATA("images/");
|
||||
if (prefix.isEmpty())
|
||||
QFAIL("can not find images directory!");
|
||||
const QString filePath = prefix + QLatin1String("designer.png");
|
||||
const QString filePath = m_prefix + QLatin1String("designer.png");
|
||||
|
||||
QPixmap original(filePath);
|
||||
QVERIFY(!original.isNull());
|
||||
@ -1344,17 +1349,15 @@ void tst_QPixmap::loadFromDataImage_data()
|
||||
{
|
||||
QTest::addColumn<QString>("imagePath");
|
||||
|
||||
const QString prefix = QFINDTESTDATA("loadFromData");
|
||||
|
||||
QTest::newRow("designer_argb32.png") << prefix + "/designer_argb32.png";
|
||||
QTest::newRow("designer_argb32.png") << m_loadFromData + "/designer_argb32.png";
|
||||
// When no extension is provided we try all extensions that has been registered by image providers
|
||||
QTest::newRow("designer_argb32") << prefix + "/designer_argb32.png";
|
||||
QTest::newRow("designer_indexed8_no_alpha.png") << prefix + "/designer_indexed8_no_alpha.png";
|
||||
QTest::newRow("designer_indexed8_with_alpha.png") << prefix + "/designer_indexed8_with_alpha.png";
|
||||
QTest::newRow("designer_rgb32.png") << prefix + "/designer_rgb32.png";
|
||||
QTest::newRow("designer_indexed8_no_alpha.gif") << prefix + "/designer_indexed8_no_alpha.gif";
|
||||
QTest::newRow("designer_indexed8_with_alpha.gif") << prefix + "/designer_indexed8_with_alpha.gif";
|
||||
QTest::newRow("designer_rgb32.jpg") << prefix + "/designer_rgb32.jpg";
|
||||
QTest::newRow("designer_argb32") << m_loadFromData + "/designer_argb32.png";
|
||||
QTest::newRow("designer_indexed8_no_alpha.png") << m_loadFromData + "/designer_indexed8_no_alpha.png";
|
||||
QTest::newRow("designer_indexed8_with_alpha.png") << m_loadFromData + "/designer_indexed8_with_alpha.png";
|
||||
QTest::newRow("designer_rgb32.png") << m_loadFromData + "/designer_rgb32.png";
|
||||
QTest::newRow("designer_indexed8_no_alpha.gif") << m_loadFromData + "/designer_indexed8_no_alpha.gif";
|
||||
QTest::newRow("designer_indexed8_with_alpha.gif") << m_loadFromData + "/designer_indexed8_with_alpha.gif";
|
||||
QTest::newRow("designer_rgb32.jpg") << m_loadFromData + "/designer_rgb32.jpg";
|
||||
}
|
||||
|
||||
void tst_QPixmap::loadFromDataImage()
|
||||
@ -1378,17 +1381,15 @@ void tst_QPixmap::fromImageReader_data()
|
||||
{
|
||||
QTest::addColumn<QString>("imagePath");
|
||||
|
||||
const QString prefix = QFINDTESTDATA("loadFromData");
|
||||
|
||||
QTest::newRow("designer_argb32.png") << prefix + "/designer_argb32.png";
|
||||
QTest::newRow("designer_indexed8_no_alpha.png") << prefix + "/designer_indexed8_no_alpha.png";
|
||||
QTest::newRow("designer_indexed8_with_alpha.png") << prefix + "/designer_indexed8_with_alpha.png";
|
||||
QTest::newRow("designer_rgb32.png") << prefix + "/designer_rgb32.png";
|
||||
QTest::newRow("designer_indexed8_no_alpha.gif") << prefix + "/designer_indexed8_no_alpha.gif";
|
||||
QTest::newRow("designer_indexed8_with_alpha.gif") << prefix + "/designer_indexed8_with_alpha.gif";
|
||||
QTest::newRow("designer_rgb32.jpg") << prefix + "/designer_rgb32.jpg";
|
||||
QTest::newRow("designer_indexed8_with_alpha_animated") << prefix + "/designer_indexed8_with_alpha_animated.gif";
|
||||
QTest::newRow("designer_indexed8_no_alpha_animated") << prefix + "/designer_indexed8_no_alpha_animated.gif";
|
||||
QTest::newRow("designer_argb32.png") << m_loadFromData + "/designer_argb32.png";
|
||||
QTest::newRow("designer_indexed8_no_alpha.png") << m_loadFromData + "/designer_indexed8_no_alpha.png";
|
||||
QTest::newRow("designer_indexed8_with_alpha.png") << m_loadFromData + "/designer_indexed8_with_alpha.png";
|
||||
QTest::newRow("designer_rgb32.png") << m_loadFromData + "/designer_rgb32.png";
|
||||
QTest::newRow("designer_indexed8_no_alpha.gif") << m_loadFromData + "/designer_indexed8_no_alpha.gif";
|
||||
QTest::newRow("designer_indexed8_with_alpha.gif") << m_loadFromData + "/designer_indexed8_with_alpha.gif";
|
||||
QTest::newRow("designer_rgb32.jpg") << m_loadFromData + "/designer_rgb32.jpg";
|
||||
QTest::newRow("designer_indexed8_with_alpha_animated") << m_loadFromData + "/designer_indexed8_with_alpha_animated.gif";
|
||||
QTest::newRow("designer_indexed8_no_alpha_animated") << m_loadFromData + "/designer_indexed8_no_alpha_animated.gif";
|
||||
}
|
||||
|
||||
void tst_QPixmap::fromImageReader()
|
||||
@ -1416,8 +1417,7 @@ void tst_QPixmap::fromImageReaderAnimatedGif()
|
||||
{
|
||||
QFETCH(QString, imagePath);
|
||||
|
||||
const QString prefix = QFINDTESTDATA("loadFromData");
|
||||
const QString path = prefix + imagePath;
|
||||
const QString path = m_loadFromData + imagePath;
|
||||
|
||||
QImageReader referenceReader(path);
|
||||
QImageReader pixmapReader(path);
|
||||
@ -1533,14 +1533,12 @@ void tst_QPixmap::scaled_QTBUG19157()
|
||||
|
||||
void tst_QPixmap::detachOnLoad_QTBUG29639()
|
||||
{
|
||||
const QString prefix = QFINDTESTDATA("convertFromImage");
|
||||
|
||||
QPixmap a;
|
||||
a.load(prefix + "/task31722_0/img1.png");
|
||||
a.load(prefix + "/task31722_0/img2.png");
|
||||
a.load(m_convertFromImage + "/task31722_0/img1.png");
|
||||
a.load(m_convertFromImage + "/task31722_0/img2.png");
|
||||
|
||||
QPixmap b;
|
||||
b.load(prefix + "/task31722_0/img1.png");
|
||||
b.load(m_convertFromImage + "/task31722_0/img1.png");
|
||||
|
||||
QVERIFY(a.toImage() != b.toImage());
|
||||
}
|
||||
|
@ -85,6 +85,7 @@ private:
|
||||
QNetworkAccessManager m_manager;
|
||||
int m_multipleRequestsCount;
|
||||
int m_multipleRepliesFinishedCount;
|
||||
const QString m_rfc3252FilePath;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *authenticator);
|
||||
@ -92,6 +93,7 @@ protected Q_SLOTS:
|
||||
};
|
||||
|
||||
tst_Spdy::tst_Spdy()
|
||||
: m_rfc3252FilePath(QFINDTESTDATA("../qnetworkreply/rfc3252.txt"))
|
||||
{
|
||||
#if defined(QT_BUILD_INTERNAL) && !defined(QT_NO_SSL) && OPENSSL_VERSION_NUMBER >= 0x1000100fL && !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
|
||||
qRegisterMetaType<QNetworkReply *>(); // for QSignalSpy
|
||||
@ -110,6 +112,7 @@ tst_Spdy::~tst_Spdy()
|
||||
|
||||
void tst_Spdy::initTestCase()
|
||||
{
|
||||
QVERIFY(!m_rfc3252FilePath.isEmpty());
|
||||
QVERIFY(QtNetworkSettings::verifyTestNetworkSettings());
|
||||
}
|
||||
|
||||
@ -215,7 +218,7 @@ void tst_Spdy::download_data()
|
||||
|
||||
QTest::newRow("mediumfile") << QUrl("https://" + QtNetworkSettings::serverName()
|
||||
+ "/qtest/rfc3252.txt")
|
||||
<< QFINDTESTDATA("../qnetworkreply/rfc3252.txt")
|
||||
<< m_rfc3252FilePath
|
||||
<< QNetworkProxy();
|
||||
|
||||
QHostInfo hostInfo = QHostInfo::fromName(QtNetworkSettings::serverName());
|
||||
@ -223,23 +226,23 @@ void tst_Spdy::download_data()
|
||||
|
||||
QTest::newRow("mediumfile-http-proxy") << QUrl("https://" + QtNetworkSettings::serverName()
|
||||
+ "/qtest/rfc3252.txt")
|
||||
<< QFINDTESTDATA("../qnetworkreply/rfc3252.txt")
|
||||
<< m_rfc3252FilePath
|
||||
<< QNetworkProxy(QNetworkProxy::HttpProxy, proxyserver, 3128);
|
||||
|
||||
QTest::newRow("mediumfile-http-proxy-auth") << QUrl("https://" + QtNetworkSettings::serverName()
|
||||
+ "/qtest/rfc3252.txt")
|
||||
<< QFINDTESTDATA("../qnetworkreply/rfc3252.txt")
|
||||
<< m_rfc3252FilePath
|
||||
<< QNetworkProxy(QNetworkProxy::HttpProxy,
|
||||
proxyserver, 3129);
|
||||
|
||||
QTest::newRow("mediumfile-socks-proxy") << QUrl("https://" + QtNetworkSettings::serverName()
|
||||
+ "/qtest/rfc3252.txt")
|
||||
<< QFINDTESTDATA("../qnetworkreply/rfc3252.txt")
|
||||
<< m_rfc3252FilePath
|
||||
<< QNetworkProxy(QNetworkProxy::Socks5Proxy, proxyserver, 1080);
|
||||
|
||||
QTest::newRow("mediumfile-socks-proxy-auth") << QUrl("https://" + QtNetworkSettings::serverName()
|
||||
+ "/qtest/rfc3252.txt")
|
||||
<< QFINDTESTDATA("../qnetworkreply/rfc3252.txt")
|
||||
<< m_rfc3252FilePath
|
||||
<< QNetworkProxy(QNetworkProxy::Socks5Proxy,
|
||||
proxyserver, 1081);
|
||||
|
||||
@ -408,7 +411,7 @@ void tst_Spdy::upload_data()
|
||||
|
||||
// 2. test uploading of files
|
||||
|
||||
QFile *file = new QFile(QFINDTESTDATA("../qnetworkreply/rfc3252.txt"));
|
||||
QFile *file = new QFile(m_rfc3252FilePath);
|
||||
file->open(QIODevice::ReadOnly);
|
||||
QTest::newRow("file-26K") << md5Url << QByteArray() << QByteArray("POST")
|
||||
<< static_cast<QObject *>(file)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the test suite of the Qt Toolkit.
|
||||
@ -916,10 +916,10 @@ bool isPathListIncluded(const QStringList &l, const QStringList &r)
|
||||
#define QT_TST_QAPP_DEBUG
|
||||
void tst_QApplication::libraryPaths()
|
||||
{
|
||||
{
|
||||
#ifndef Q_OS_WINCE
|
||||
QString testDir = QFileInfo(QFINDTESTDATA("test/test.pro")).absolutePath();
|
||||
#else
|
||||
const QString testDir = QFileInfo(QFINDTESTDATA("test/test.pro")).absolutePath();
|
||||
QVERIFY(!testDir.isEmpty());
|
||||
#else // !Q_OS_WINCE
|
||||
// On Windows CE we need QApplication object to have valid
|
||||
// current Path. Therefore we need to identify it ourselves
|
||||
// here for the test.
|
||||
@ -927,8 +927,9 @@ void tst_QApplication::libraryPaths()
|
||||
wchar_t module_name[MAX_PATH];
|
||||
GetModuleFileName(0, module_name, MAX_PATH);
|
||||
filePath = QString::fromWCharArray(module_name);
|
||||
QString testDir = filePath.path() + "/test";
|
||||
#endif
|
||||
const QString testDir = filePath.path() + "/test";
|
||||
#endif // Q_OS_WINCE
|
||||
{
|
||||
QApplication::setLibraryPaths(QStringList() << testDir);
|
||||
QCOMPARE(QApplication::libraryPaths(), (QStringList() << testDir));
|
||||
|
||||
@ -964,8 +965,7 @@ void tst_QApplication::libraryPaths()
|
||||
"\nexpected:\n - " + expected.join("\n - ")));
|
||||
|
||||
// setting the library paths overrides everything
|
||||
QString testDir = QFileInfo(QFINDTESTDATA("test/test.pro")).absolutePath();
|
||||
QApplication::setLibraryPaths(QStringList() << testDir);
|
||||
QApplication::setLibraryPaths(QStringList() << testDir);
|
||||
QVERIFY2(isPathListIncluded(QApplication::libraryPaths(), (QStringList() << testDir)),
|
||||
qPrintable("actual:\n - " + QApplication::libraryPaths().join("\n - ") +
|
||||
"\nexpected:\n - " + testDir));
|
||||
@ -987,7 +987,6 @@ void tst_QApplication::libraryPaths()
|
||||
qDebug() << "After adding plugins path:" << QApplication::libraryPaths();
|
||||
#endif
|
||||
QCOMPARE(QApplication::libraryPaths().count(), count);
|
||||
QString testDir = QFileInfo(QFINDTESTDATA("test/test.pro")).absolutePath();
|
||||
QApplication::addLibraryPath(testDir);
|
||||
QCOMPARE(QApplication::libraryPaths().count(), count + 1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user