diff options
author | hjk <qthjk@ovi.com> | 2011-11-19 00:09:53 +0100 |
---|---|---|
committer | hjk <qthjk@ovi.com> | 2011-11-21 13:13:56 +0100 |
commit | 7efffd39ff3369d788a710819882b936a194956c (patch) | |
tree | bd4e37a6d381c75ce34b4a0e4b01cd622c29493a | |
parent | 7d5c4a721178f35434d793c9a0235ad8a077da7a (diff) |
Fix style in tests.
Change-Id: Icebeec79fe25a65e71a8887ebf0f5ca751388cd1
Reviewed-by: Tim Jenssen <tim.jenssen@nokia.com>
4 files changed, 71 insertions, 57 deletions
diff --git a/installerbuilder/tests/environmentvariable/environmentvariabletest.cpp b/installerbuilder/tests/environmentvariable/environmentvariabletest.cpp index f53bb46b0..d7582828b 100644 --- a/installerbuilder/tests/environmentvariable/environmentvariabletest.cpp +++ b/installerbuilder/tests/environmentvariable/environmentvariabletest.cpp @@ -77,7 +77,8 @@ void EnvironmentVariableTest::testPersistentNonSystem() settings.remove(key); } -void EnvironmentVariableTest::testNonPersistentNonSystem() { +void EnvironmentVariableTest::testNonPersistentNonSystem() +{ #ifndef Q_OS_WIN QSKIP("This operation only works on Windows",SkipSingle); #endif diff --git a/installerbuilder/tests/environmentvariable/environmentvariabletest.h b/installerbuilder/tests/environmentvariable/environmentvariabletest.h index 9028b051d..56cd7c407 100644 --- a/installerbuilder/tests/environmentvariable/environmentvariabletest.h +++ b/installerbuilder/tests/environmentvariable/environmentvariabletest.h @@ -30,14 +30,16 @@ #include <QtTest/QtTest> -class EnvironmentVariableTest : public QObject { +class EnvironmentVariableTest : public QObject +{ Q_OBJECT + public: EnvironmentVariableTest(); + private Q_SLOTS: void testPersistentNonSystem(); void testNonPersistentNonSystem(); -private: }; #endif // EXTRACTARCHIVEOPERATIONTEST_H diff --git a/installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.cpp b/installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.cpp index 475297e34..6adb74a20 100644 --- a/installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.cpp +++ b/installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.cpp @@ -30,6 +30,7 @@ ** (qt-info@nokia.com). ** **************************************************************************/ + #include "extractarchiveoperationtest.h" #include "extractarchiveoperation.h" @@ -47,29 +48,31 @@ ExtractArchiveOperationTest::ExtractArchiveOperationTest() QInstaller::init(); } -void ExtractArchiveOperationTest::init( const QString& outdir ) { - if ( QDir( outdir ).exists() ) { - QFAIL( "output directory already exists!" ); - QVERIFY( false ); +void ExtractArchiveOperationTest::init(const QString &outdir) +{ + if (QDir(outdir).exists()) { + QFAIL("output directory already exists!"); + QVERIFY(false); } - QDir cd( QDir::current() ); - QVERIFY( cd.mkdir( outdir ) ); + QDir cd(QDir::current()); + QVERIFY(cd.mkdir(outdir)); } -static bool recursiveRemove( const QString& path, QString* errorMsg ) { - if ( errorMsg ) +static bool recursiveRemove(const QString &path, QString *errorMsg) +{ + if (errorMsg) errorMsg->clear(); - if ( !QFileInfo( path ).exists() ) + if (!QFileInfo(path).exists()) return true; bool error = false; QString msg; //first, delete all non-dir files - QDirIterator it( path, QDirIterator::Subdirectories ); - while ( it.hasNext() ) { + QDirIterator it(path, QDirIterator::Subdirectories); + while (it.hasNext()) { const QString n = it.next(); - if ( !QFileInfo( n ).isDir() ) { - QFile file( n ); - if ( !file.remove() ) { + if (!QFileInfo(n).isDir()) { + QFile file(n); + if (!file.remove()) { error = true; msg = file.errorString(); } @@ -77,86 +80,90 @@ static bool recursiveRemove( const QString& path, QString* errorMsg ) { } QStack<QString> dirs; - QDirIterator it2( path, QDirIterator::Subdirectories ); - while ( it2.hasNext() ) { + QDirIterator it2(path, QDirIterator::Subdirectories); + while (it2.hasNext()) { const QString n = it2.next(); - if ( !n.endsWith( QLatin1String( "/." ) ) && !n.endsWith( QLatin1String( "/.." ) ) ) - dirs.push( n ); + if (!n.endsWith(QLatin1String( "/." ) ) && !n.endsWith( QLatin1String( "/.." ))) + dirs.push(n); } - while ( !dirs.isEmpty() ) { + while (!dirs.isEmpty()) { const QString n = dirs.top(); dirs.pop(); - if ( !QDir( n ).rmdir( QDir::currentPath() + QLatin1String( "/" ) + n ) ) { + if (!QDir(n).rmdir(QDir::currentPath() + QLatin1String("/") + n)) { error = true; - msg = QObject::tr("Could not remove folder %1").arg( n ); + msg = QObject::tr("Could not remove folder %1").arg(n); qDebug() << msg; } } - if ( !QDir( path ).rmdir( QDir::currentPath() + QLatin1String( "/" ) + path ) ) { + if (!QDir(path).rmdir(QDir::currentPath() + QLatin1String("/") + path)) { error = true; - msg = QObject::tr("Could not remove folder %1: Unknown error").arg( path ); + msg = QObject::tr("Could not remove folder %1: Unknown error").arg(path); } - if ( errorMsg ) + if (errorMsg) *errorMsg = msg; return !error; } -void ExtractArchiveOperationTest::cleanup( const QString& dir ) { - QDir d( dir ); +void ExtractArchiveOperationTest::cleanup(const QString &dir) +{ + QDir d(dir); QString msg; - const bool removed = recursiveRemove( dir, &msg ); - if ( !removed ) + const bool removed = recursiveRemove(dir, &msg); + if (!removed) qCritical() << msg; - QVERIFY( removed ); + QVERIFY(removed); } -void ExtractArchiveOperationTest::testExtraction() { +void ExtractArchiveOperationTest::testExtraction() +{ const QString outdir = QLatin1String("test-extract-out" ); - init( outdir ); + init(outdir); KDUpdater::Application app; QInstaller::ExtractArchiveOperation op; - op.setArguments( QStringList() << QLatin1String("qt-bin-test.7z") << outdir ); + op.setArguments(QStringList() << QLatin1String("qt-bin-test.7z") << outdir); const bool ok = op.performOperation(); - if ( !ok ) { + if (!ok) { qCritical() << "Extraction failed:" << op.errorString(); - QFAIL( "Extraction failed" ); + QFAIL("Extraction failed"); } - cleanup( outdir ); + cleanup(outdir); } -void ExtractArchiveOperationTest::testExtractionErrors() { - const QString outdir = QLatin1String("test-extract-out" ); - init( outdir ); +void ExtractArchiveOperationTest::testExtractionErrors() +{ + const QString outdir = QLatin1String("test-extract-out"); + init(outdir); KDUpdater::Application app; QInstaller::ExtractArchiveOperation op; - op.setArguments( QStringList() << QLatin1String("qt-bin-test.7z") << outdir ); + op.setArguments(QStringList() << QLatin1String("qt-bin-test.7z") << outdir); const bool ok = op.performOperation(); - if ( !ok ) { + if (!ok) { qCritical() << "Extraction failed:" << op.errorString(); - QFAIL( "Extraction failed" ); + QFAIL("Extraction failed"); } - cleanup( outdir ); + cleanup(outdir); } -void ExtractArchiveOperationTest::testInvalidArchive() { - const QString outdir = QLatin1String("test-extract-out" ); - init( outdir ); +void ExtractArchiveOperationTest::testInvalidArchive() +{ + const QString outdir = QLatin1String("test-extract-out"); + init(outdir); KDUpdater::Application app; QInstaller::ExtractArchiveOperation op; - op.setArguments( QStringList() << QLatin1String("test-noarchive.7z") << outdir ); + op.setArguments(QStringList() << QLatin1String("test-noarchive.7z") << outdir); const bool ok = op.performOperation(); - if ( ok ) { + if (ok) { qCritical() << "ExtractArchiveOperation does not report error on extracting invalid archive"; - QFAIL( "Extraction failed" ); + QFAIL("Extraction failed"); } - QVERIFY( op.error() != QInstaller::ExtractArchiveOperation::NoError ); + QVERIFY(op.error() != QInstaller::ExtractArchiveOperation::NoError); const QString str = op.errorString(); qDebug() << str; - QVERIFY( !str.isEmpty() ); - cleanup( outdir ); + QVERIFY(!str.isEmpty()); + cleanup(outdir); } QTEST_MAIN(ExtractArchiveOperationTest) diff --git a/installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.h b/installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.h index be5169426..ed34561a0 100644 --- a/installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.h +++ b/installerbuilder/tests/extractarchiveoperationtest/extractarchiveoperationtest.h @@ -30,17 +30,21 @@ #include <QtTest/QtTest> -class ExtractArchiveOperationTest : public QObject { +class ExtractArchiveOperationTest : public QObject +{ Q_OBJECT + public: ExtractArchiveOperationTest(); + private Q_SLOTS: void testExtraction(); void testInvalidArchive(); void testExtractionErrors(); + private: - void init( const QString& ); - void cleanup( const QString& ); + void init(const QString &); + void cleanup(const QString &); }; #endif // EXTRACTARCHIVEOPERATIONTEST_H |