diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-12-04 18:36:19 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-12-04 18:36:19 (GMT) |
commit | f0bb9bc5b0f4c20536d6c77624bd148389b78c06 (patch) | |
tree | 9088a173de4bfbeea29bc9464d4cb46257df67cd /tests | |
parent | 60be72310c0f9469b3201b250b257473184ccf2a (diff) | |
parent | 1bb5999cdca0a70df3f96d596c83c3cf7c97c5fd (diff) | |
download | Qt-f0bb9bc5b0f4c20536d6c77624bd148389b78c06.zip Qt-f0bb9bc5b0f4c20536d6c77624bd148389b78c06.tar.gz Qt-f0bb9bc5b0f4c20536d6c77624bd148389b78c06.tar.bz2 |
Merge commit 'origin/4.6' into 4.6
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qfile/tst_qfile.cpp | 13 | ||||
-rw-r--r-- | tests/auto/qfileinfo/tst_qfileinfo.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qlibrary/lib/lib.pro | 14 | ||||
-rw-r--r-- | tests/auto/qlibrary/lib2/lib2.pro | 22 | ||||
-rw-r--r-- | tests/auto/qlibrary/tst_qlibrary.cpp | 50 | ||||
-rw-r--r-- | tests/auto/qlineedit/tst_qlineedit.cpp | 37 | ||||
-rw-r--r-- | tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 3 | ||||
-rw-r--r-- | tests/auto/qscriptengine/tst_qscriptengine.cpp | 18 | ||||
-rw-r--r-- | tests/auto/qsqldatabase/tst_qsqldatabase.cpp | 16 | ||||
-rw-r--r-- | tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp | 9 | ||||
-rw-r--r-- | tests/benchmarks/benchmarks.pro | 1 | ||||
-rw-r--r-- | tests/benchmarks/qdir/tst_qdir.cpp | 3 | ||||
-rw-r--r-- | tests/benchmarks/qfileinfo/main.cpp | 83 | ||||
-rw-r--r-- | tests/benchmarks/qfileinfo/qfileinfo.pro | 12 |
14 files changed, 231 insertions, 54 deletions
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index cf46ce1..7ee5665 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -2783,10 +2783,21 @@ void tst_QFile::mapOpenMode() void tst_QFile::openDirectory() { - QFile f1("resources"); + QFile f1(SRCDIR "resources"); + // it's a directory, it must exist + QVERIFY(f1.exists()); + + // ...but not be openable QVERIFY(!f1.open(QIODevice::ReadOnly)); f1.close(); QVERIFY(!f1.open(QIODevice::ReadOnly|QIODevice::Unbuffered)); + f1.close(); + QVERIFY(!f1.open(QIODevice::ReadWrite)); + f1.close(); + QVERIFY(!f1.open(QIODevice::WriteOnly)); + f1.close(); + QVERIFY(!f1.open(QIODevice::WriteOnly|QIODevice::Unbuffered)); + f1.close(); } void tst_QFile::openStandardStreams() diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 21edbcf..cd58fd6 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -513,6 +513,10 @@ void tst_QFileInfo::canonicalFilePath() QFileInfo info("/tmp/../../../../../../../../../../../../../../../../../"); info.canonicalFilePath(); + // This used to crash on Mac + QFileInfo dontCrash(QLatin1String("/")); + QCOMPARE(dontCrash.canonicalFilePath(), QLatin1String("/")); + #ifndef Q_OS_WIN // test symlinks QFile::remove("link.lnk"); diff --git a/tests/auto/qlibrary/lib/lib.pro b/tests/auto/qlibrary/lib/lib.pro index 25a50b5..6d80881 100644 --- a/tests/auto/qlibrary/lib/lib.pro +++ b/tests/auto/qlibrary/lib/lib.pro @@ -10,20 +10,6 @@ wince*: DEFINES += WIN32_MSVC win32-msvc: DEFINES += WIN32_MSVC win32-borland: DEFINES += WIN32_BORLAND -# Force a copy of the library to have an extension that is non-standard. -# We want to test if we can load a shared library with *any* filename... - -# For windows test if we can load a filename with multiple dots. -win32: { - QMAKE_POST_LINK = copy /Y $(DESTDIR_TARGET) ..\mylib.dl2 && \ - copy /Y $(DESTDIR_TARGET) ..\system.trolltech.test.mylib.dll && \ - copy /Y $(DESTDIR_TARGET) ..\mylib_noextension -} -unix:!symbian: { - QMAKE_POST_LINK = cp -f $(DESTDIR)$(TARGET) ../libmylib.so2 && \ - cp -f $(DESTDIR)$(TARGET) ../system.trolltech.test.mylib.so -} - #no special install rule for the library used by test INSTALLS = diff --git a/tests/auto/qlibrary/lib2/lib2.pro b/tests/auto/qlibrary/lib2/lib2.pro index fc00af8..da30a2d 100644 --- a/tests/auto/qlibrary/lib2/lib2.pro +++ b/tests/auto/qlibrary/lib2/lib2.pro @@ -14,15 +14,19 @@ win32-borland: DEFINES += WIN32_BORLAND # Force a copy of the library to have an extension that is non-standard. # We want to test if we can load a shared library with *any* filename... -# For windows test if we can load a filename with multiple dots. -win32: { - QMAKE_POST_LINK = copy /Y ..\mylib2.dll ..\mylib.dl2 && \ - copy /Y ..\mylib2.dll ..\system.trolltech.test.mylib.dll -} - -unix:!symbian: { - QMAKE_POST_LINK = cp -f $(DESTDIR)$(TARGET) ../libmylib.so2 && \ - cp -f $(DESTDIR)$(TARGET) ../system.trolltech.test.mylib.so +!symbian { + win32 { + src = $(DESTDIR_TARGET) + files = mylib.dl2 system.trolltech.test.mylib.dll + } else { + src = $(DESTDIR)$(TARGET) + files = libmylib.so2 system.trolltech.test.mylib.so + } + for(file, files) { + QMAKE_POST_LINK += $(COPY) $$src ..$$QMAKE_DIR_SEP$$file && + CLEAN_FILES += ../$$file + } + QMAKE_POST_LINK = $$member(QMAKE_POST_LINK, 0, -2) } symbian-abld: { diff --git a/tests/auto/qlibrary/tst_qlibrary.cpp b/tests/auto/qlibrary/tst_qlibrary.cpp index ca6db9a..c7f52bc 100644 --- a/tests/auto/qlibrary/tst_qlibrary.cpp +++ b/tests/auto/qlibrary/tst_qlibrary.cpp @@ -218,22 +218,22 @@ void tst_QLibrary::load_data() #else QString currDir = QDir::currentPath(); #endif - QTest::newRow( "ok00" ) << currDir + "/mylib" << (bool)true; - QTest::newRow( "notexist" ) << currDir + "/nolib" << (bool)false; - QTest::newRow( "badlibrary" ) << currDir + "/qlibrary.pro" << (bool)false; + QTest::newRow( "ok00" ) << currDir + "/mylib" << true; + QTest::newRow( "notexist" ) << currDir + "/nolib" << false; + QTest::newRow( "badlibrary" ) << currDir + "/qlibrary.pro" << false; #ifdef Q_OS_MAC - QTest::newRow("ok (libmylib ver. 1)") << currDir + "/libmylib" <<(bool)true; + QTest::newRow("ok (libmylib ver. 1)") << currDir + "/libmylib" <<true; #endif # if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) - QTest::newRow( "ok01 (with suffix)" ) << currDir + "/mylib.dll" << (bool)true; - QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/mylib.dl2" << (bool)true; - QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.dll" << (bool)true; + QTest::newRow( "ok01 (with suffix)" ) << currDir + "/mylib.dll" << true; + QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/mylib.dl2" << true; + QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.dll" << true; # elif defined Q_OS_UNIX - QTest::newRow( "ok01 (with suffix)" ) << currDir + "/libmylib" SUFFIX << (bool)true; - QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/libmylib.so2" << (bool)true; - QTest::newRow( "ok03 (with non-standard suffix)" ) << currDir + "/system.trolltech.test.mylib.so" << (bool)true; + QTest::newRow( "ok01 (with suffix)" ) << currDir + "/libmylib" SUFFIX << true; + QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/libmylib.so2" << true; + QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.so" << true; # endif // Q_OS_UNIX } @@ -262,12 +262,12 @@ void tst_QLibrary::unload_data() QString currDir = QDir::currentPath(); #endif - QTest::newRow( "mylib" ) << currDir + "/mylib" << (bool)TRUE; + QTest::newRow( "mylib" ) << currDir + "/mylib" << true; #ifdef Q_WS_MAC if (QSysInfo::MacintoshVersion <= QSysInfo::MV_10_3) QEXPECT_FAIL("mylib", "dlcompat cannot unload libraries", Continue); #endif - QTest::newRow( "ok01" ) << currDir + "/nolib" << (bool)FALSE; + QTest::newRow( "ok01" ) << currDir + "/nolib" << false; } void tst_QLibrary::unload() @@ -312,9 +312,9 @@ void tst_QLibrary::resolve_data() QString currDir = QDir::currentPath(); #endif - QTest::newRow( "ok00" ) << currDir + "/mylib" << QString("mylibversion") << (bool)TRUE; - QTest::newRow( "bad00" ) << currDir + "/mylib" << QString("nosym") << (bool)FALSE; - QTest::newRow( "bad01" ) << currDir + "/nolib" << QString("nosym") << (bool)FALSE; + QTest::newRow( "ok00" ) << currDir + "/mylib" << QString("mylibversion") << true; + QTest::newRow( "bad00" ) << currDir + "/mylib" << QString("nosym") << false; + QTest::newRow( "bad01" ) << currDir + "/nolib" << QString("nosym") << false; } void tst_QLibrary::resolve() @@ -479,9 +479,9 @@ void tst_QLibrary::loadHints_data() #if defined(Q_OS_AIX) if (QFile::exists("/usr/lib/libGL.a") || QFile::exists("/usr/X11R6/lib/libGL.a")) { # if QT_POINTER_SIZE == 4 - QTest::newRow( "ok03 (Archive member)" ) << "libGL.a(shr.o)" << int(QLibrary::LoadArchiveMemberHint) << (bool)TRUE; + QTest::newRow( "ok03 (Archive member)" ) << "libGL.a(shr.o)" << int(QLibrary::LoadArchiveMemberHint) << true; # else - QTest::newRow( "ok03 (Archive member)" ) << "libGL.a(shr_64.o)" << int(QLibrary::LoadArchiveMemberHint) << (bool)TRUE; + QTest::newRow( "ok03 (Archive member)" ) << "libGL.a(shr_64.o)" << int(QLibrary::LoadArchiveMemberHint) << true; #endif } #endif @@ -494,13 +494,13 @@ void tst_QLibrary::loadHints_data() lh |= QLibrary::ResolveAllSymbolsHint; # if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) - QTest::newRow( "ok01 (with suffix)" ) << currDir + "/mylib.dll" << int(lh) << (bool)TRUE; - QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/mylib.dl2" << int(lh) << (bool)TRUE; - QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.dll" << int(lh) << (bool)TRUE; + QTest::newRow( "ok01 (with suffix)" ) << currDir + "/mylib.dll" << int(lh) << true; + QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/mylib.dl2" << int(lh) << true; + QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.dll" << int(lh) << true; # elif defined Q_OS_UNIX - QTest::newRow( "ok01 (with suffix)" ) << currDir + "/libmylib" SUFFIX << int(lh) << (bool)TRUE; - QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/libmylib.so2" << int(lh) << (bool)TRUE; - QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.so" << int(lh) << (bool)TRUE; + QTest::newRow( "ok01 (with suffix)" ) << currDir + "/libmylib" SUFFIX << int(lh) << true; + QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/libmylib.so2" << int(lh) << true; + QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.so" << int(lh) << true; # endif // Q_OS_UNIX } @@ -535,10 +535,10 @@ void tst_QLibrary::fileName_data() << sys_qualifiedLibraryName(QLatin1String("mylib")); #ifdef Q_WS_WIN #ifndef Q_OS_WINCE - QTest::newRow( "ok02" ) << "user32" + QTest::newRow( "ok03" ) << "user32" << "USER32.dll"; #else - QTest::newRow( "ok02" ) << "coredll" + QTest::newRow( "ok03" ) << "coredll" << "coredll.dll"; #endif #endif diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index 8b8078b..fa2b9bd 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -269,6 +269,8 @@ private slots: void task241436_passwordEchoOnEditRestoreEchoMode(); void task248948_redoRemovedSelection(); void taskQTBUG_4401_enterKeyClearsPassword(); + void taskQTBUG_4679_moveToStartEndOfBlock(); + void taskQTBUG_4679_selectToStartEndOfBlock(); protected slots: #ifdef QT3_SUPPORT @@ -3601,5 +3603,40 @@ void tst_QLineEdit::taskQTBUG_4401_enterKeyClearsPassword() QTRY_COMPARE(testWidget->text(), password); } +void tst_QLineEdit::taskQTBUG_4679_moveToStartEndOfBlock() +{ +#ifdef Q_OS_MAC + const QString text("there are no blocks for lineEdit"); + testWidget->setText(text); + testWidget->setCursorPosition(5); + QCOMPARE(testWidget->cursorPosition(), 5); + testWidget->setFocus(); + QTest::keyPress(testWidget, Qt::Key_A, Qt::MetaModifier); + QCOMPARE(testWidget->cursorPosition(), 0); + QTest::keyPress(testWidget, Qt::Key_E, Qt::MetaModifier); + QCOMPARE(testWidget->cursorPosition(), text.size()); +#endif // Q_OS_MAC +} + +void tst_QLineEdit::taskQTBUG_4679_selectToStartEndOfBlock() +{ +#ifdef Q_OS_MAC + const QString text("there are no blocks for lineEdit, select all"); + testWidget->setText(text); + testWidget->setCursorPosition(5); + QCOMPARE(testWidget->cursorPosition(), 5); + testWidget->setFocus(); + QTest::keyPress(testWidget, Qt::Key_A, Qt::MetaModifier | Qt::ShiftModifier); + QCOMPARE(testWidget->cursorPosition(), 0); + QVERIFY(testWidget->hasSelectedText()); + QCOMPARE(testWidget->selectedText(), text.mid(0, 5)); + + QTest::keyPress(testWidget, Qt::Key_E, Qt::MetaModifier | Qt::ShiftModifier); + QCOMPARE(testWidget->cursorPosition(), text.size()); + QVERIFY(testWidget->hasSelectedText()); + QCOMPARE(testWidget->selectedText(), text.mid(5)); +#endif // Q_OS_MAC +} + QTEST_MAIN(tst_QLineEdit) #include "tst_qlineedit.moc" diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 5fe716a..6d43c1d 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -3241,8 +3241,11 @@ void tst_QNetworkReply::receiveCookiesFromHttp_data() cookie = QNetworkCookie("a", "b"); cookie.setPath("/not/part-of-path"); header << cookie; + cookie.setDomain(QtNetworkSettings::serverName()); + jar << cookie; QTest::newRow("invalid-cookie-path") << "a=b; path=/not/part-of-path" << header << jar; + jar.clear(); cookie = QNetworkCookie("a", "b"); cookie.setDomain(".example.com"); header.clear(); diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 3bc2443..2d629b7 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -154,6 +154,7 @@ private slots: void functionScopes(); void nativeFunctionScopes(); void evaluateProgram(); + void collectGarbageAfterConnect(); void qRegExpInport_data(); void qRegExpInport(); @@ -4443,6 +4444,23 @@ void tst_QScriptEngine::evaluateProgram() } } +void tst_QScriptEngine::collectGarbageAfterConnect() +{ + // QTBUG-6366 + QScriptEngine engine; + QPointer<QWidget> widget = new QWidget; + engine.globalObject().setProperty( + "widget", engine.newQObject(widget, QScriptEngine::ScriptOwnership)); + QVERIFY(engine.evaluate("widget.customContextMenuRequested.connect(\n" + " function() { print('hello'); }\n" + ");") + .isUndefined()); + QVERIFY(widget != 0); + engine.evaluate("widget = null;"); + collectGarbage_helper(engine); + QVERIFY(widget == 0); +} + static QRegExp minimal(QRegExp r) { r.setMinimal(true); return r; } void tst_QScriptEngine::qRegExpInport_data() diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index fe7c3ea..f840ca6 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -86,6 +86,8 @@ private slots: void open(); void tables_data() { generic_data(); } void tables(); + void oci_tables_data() { generic_data("QOCI"); } + void oci_tables(); void transaction_data() { generic_data(); } void transaction(); void eventNotification_data() { generic_data(); } @@ -380,6 +382,7 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db) if (db.driverName().startsWith("QOCI")) { q.exec("drop user "+qTableName("CREATOR")+" cascade"); q.exec("drop user "+qTableName("APPUSER")+" cascade"); + q.exec("DROP TABLE system."+qTableName("mypassword")); } } @@ -2481,5 +2484,18 @@ void tst_QSqlDatabase::mysql_savepointtest() QVERIFY_SQL(q, exec("savepoint foo")); } +void tst_QSqlDatabase::oci_tables() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + QSqlQuery q(db); + QString systemTableName("system."+qTableName("mypassword")); + QVERIFY_SQL(q, exec("CREATE TABLE "+systemTableName+"(name VARCHAR(20))")); + QVERIFY(!db.tables().contains(systemTableName.toUpper())); + qDebug() << db.tables(QSql::SystemTables); + QVERIFY(db.tables(QSql::SystemTables).contains(systemTableName.toUpper())); +} + QTEST_MAIN(tst_QSqlDatabase) #include "tst_qsqldatabase.moc" diff --git a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp index 8c840cd..4ae5000 100644 --- a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp +++ b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp @@ -1212,10 +1212,11 @@ void tst_QSqlRelationalTableModel::psqlSchemaTest() QSqlQuery q(db); QVERIFY_SQL(q, exec("create schema "+qTableName("QTBUG_5373"))); QVERIFY_SQL(q, exec("create schema "+qTableName("QTBUG_5373_s2"))); - QVERIFY_SQL(q, exec("create table "+qTableName("QTBUG_5373")+"."+qTableName("user")+"(userid int primary key, relatingid int)")); - QVERIFY_SQL(q, exec("create table "+qTableName("QTBUG_5373_s2")+"."+qTableName("user2")+"(userid2 int primary key, username2 char(40))")); - model.setTable(qTableName("QTBUG_5373")+"."+qTableName("user")); - model.setRelation(1, QSqlRelation(qTableName("QTBUG_5373_s2")+"."+qTableName("user2"), "userid2", "username2")); + QVERIFY_SQL(q, exec("create table "+qTableName("QTBUG_5373")+"."+qTableName("document")+"(document_id int primary key, relatingid int, userid int)")); + QVERIFY_SQL(q, exec("create table "+qTableName("QTBUG_5373_s2")+"."+qTableName("user")+"(userid int primary key, username char(40))")); + model.setTable(qTableName("QTBUG_5373")+"."+qTableName("document")); + model.setRelation(1, QSqlRelation(qTableName("QTBUG_5373_s2")+"."+qTableName("user"), "userid", "username")); + model.setRelation(2, QSqlRelation(qTableName("QTBUG_5373_s2")+"."+qTableName("user"), "userid", "username")); QVERIFY_SQL(model, select()); } diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro index a63fb41..9170039 100644 --- a/tests/benchmarks/benchmarks.pro +++ b/tests/benchmarks/benchmarks.pro @@ -3,6 +3,7 @@ SUBDIRS = containers-associative \ containers-sequential \ qanimation \ qbytearray \ + qfileinfo \ qfile_vs_qnetworkaccessmanager \ qpainter \ qtestlib-simple events \ diff --git a/tests/benchmarks/qdir/tst_qdir.cpp b/tests/benchmarks/qdir/tst_qdir.cpp index 2e4a28a..fd558d3 100644 --- a/tests/benchmarks/qdir/tst_qdir.cpp +++ b/tests/benchmarks/qdir/tst_qdir.cpp @@ -68,7 +68,8 @@ public slots: void cleanupTestCase() { { QDir testdir(QDir::tempPath() + QLatin1String("/test_speed")); - + testdir.setSorting(QDir::Unsorted); + testdir.setFilter(QDir::AllEntries | QDir::System | QDir::Hidden); foreach (const QString &filename, testdir.entryList()) { testdir.remove(filename); } diff --git a/tests/benchmarks/qfileinfo/main.cpp b/tests/benchmarks/qfileinfo/main.cpp new file mode 100644 index 0000000..711209c --- /dev/null +++ b/tests/benchmarks/qfileinfo/main.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QDebug> +#include <qtest.h> +#include <QtTest/QtTest> +#include <QtCore/QCoreApplication> +#include <QtCore/QFileInfo> + +#include "private/qfsfileengine_p.h" + +class qfileinfo : public QObject +{ + Q_OBJECT +private slots: + void canonicalFileNamePerformance(); + + void initTestCase(); + void cleanupTestCase(); +public: + qfileinfo() : QObject() {}; +}; + +void qfileinfo::initTestCase() +{ +} + +void qfileinfo::cleanupTestCase() +{ +} + +void qfileinfo::canonicalFileNamePerformance() +{ + QString appPath = QCoreApplication::applicationFilePath(); + QFSFileEnginePrivate::canonicalized(appPath); // warmup + QFSFileEnginePrivate::canonicalized(appPath); // more warmup + QBENCHMARK { + for (int i = 0; i < 5000; i++) { + QFSFileEnginePrivate::canonicalized(appPath); + } + } +} + +QTEST_MAIN(qfileinfo) + +#include "main.moc" diff --git a/tests/benchmarks/qfileinfo/qfileinfo.pro b/tests/benchmarks/qfileinfo/qfileinfo.pro new file mode 100644 index 0000000..295cb50 --- /dev/null +++ b/tests/benchmarks/qfileinfo/qfileinfo.pro @@ -0,0 +1,12 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = qfileinfo +DEPENDPATH += . +INCLUDEPATH += . + +QT -= gui + +CONFIG += release + +# Input +SOURCES += main.cpp |