diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2011-04-14 04:47:16 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2011-04-14 04:47:16 (GMT) |
commit | cc3bcc003048760a501debe49b6fcebffaac3cef (patch) | |
tree | 5d8d8e5ea0cd1c9dffc6abd3e6e40058536236c8 /tests | |
parent | a5d5971586d0a12e55374dae30e17454bca12600 (diff) | |
parent | 662174b78b7e08c759d0086e215e81e9e0eaf0c5 (diff) | |
download | Qt-cc3bcc003048760a501debe49b6fcebffaac3cef.zip Qt-cc3bcc003048760a501debe49b6fcebffaac3cef.tar.gz Qt-cc3bcc003048760a501debe49b6fcebffaac3cef.tar.bz2 |
Merge branch 'master' of ../qt-qml-staging
Diffstat (limited to 'tests')
61 files changed, 1543 insertions, 263 deletions
diff --git a/tests/arthur/common/baselineprotocol.cpp b/tests/arthur/common/baselineprotocol.cpp index 0e7e507..88cea36 100644 --- a/tests/arthur/common/baselineprotocol.cpp +++ b/tests/arthur/common/baselineprotocol.cpp @@ -50,6 +50,18 @@ #include <QTime> #include <QPointer> +const QString PI_TestCase(QLS("TestCase")); +const QString PI_HostName(QLS("HostName")); +const QString PI_HostAddress(QLS("HostAddress")); +const QString PI_OSName(QLS("OSName")); +const QString PI_OSVersion(QLS("OSVersion")); +const QString PI_QtVersion(QLS("QtVersion")); +const QString PI_BuildKey(QLS("BuildKey")); +const QString PI_GitCommit(QLS("GitCommit")); +const QString PI_QMakeSpec(QLS("QMakeSpec")); +const QString PI_PulseGitBranch(QLS("PulseGitBranch")); +const QString PI_PulseTestrBranch(QLS("PulseTestrBranch")); + #ifndef QMAKESPEC #define QMAKESPEC "Unknown" #endif @@ -70,60 +82,117 @@ void BaselineProtocol::sysSleep(int ms) #endif } -PlatformInfo::PlatformInfo(bool useLocal) - : QMap<QString, QString>() +PlatformInfo::PlatformInfo() + : QMap<QString, QString>(), replaceDefault(false) { - if (useLocal) { - insert(PI_HostName, QHostInfo::localHostName()); - insert(PI_QtVersion, QLS(qVersion())); - insert(PI_QMakeSpec, QString(QLS(QMAKESPEC)).remove(QRegExp(QLS("^.*mkspecs/")))); - insert(PI_BuildKey, QLibraryInfo::buildKey()); +} + +PlatformInfo PlatformInfo::localHostInfo() +{ + PlatformInfo pi; + pi.insert(PI_HostName, QHostInfo::localHostName()); + pi.insert(PI_QtVersion, QLS(qVersion())); + pi.insert(PI_QMakeSpec, QString(QLS(QMAKESPEC)).remove(QRegExp(QLS("^.*mkspecs/")))); + pi.insert(PI_BuildKey, QLibraryInfo::buildKey()); #if defined(Q_OS_LINUX) - insert(PI_OSName, QLS("Linux")); - QProcess uname; - uname.start(QLS("uname"), QStringList() << QLS("-r")); - if (uname.waitForFinished(3000)) - insert(PI_OSVersion, QString::fromLocal8Bit(uname.readAllStandardOutput().constData()).simplified()); + pi.insert(PI_OSName, QLS("Linux")); + QProcess uname; + uname.start(QLS("uname"), QStringList() << QLS("-r")); + if (uname.waitForFinished(3000)) + pi.insert(PI_OSVersion, QString::fromLocal8Bit(uname.readAllStandardOutput().constData()).simplified()); #elif defined(Q_OS_WINCE) - insert(PI_OSName, QLS("WinCE")); - insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion())); + pi.insert(PI_OSName, QLS("WinCE")); + pi.insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion())); #elif defined(Q_OS_WIN) - insert(PI_OSName, QLS("Windows")); - insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion())); + pi.insert(PI_OSName, QLS("Windows")); + pi.insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion())); #elif defined(Q_OS_MAC) - insert(PI_OSName, QLS("MacOS")); - insert(PI_OSVersion, QString::number(qMacVersion())); + pi.insert(PI_OSName, QLS("MacOS")); + pi.insert(PI_OSVersion, QString::number(qMacVersion())); #elif defined(Q_OS_SYMBIAN) - insert(PI_OSName, QLS("Symbian")); - insert(PI_OSVersion, QString::number(QSysInfo::symbianVersion()); + pi.insert(PI_OSName, QLS("Symbian")); + pi.insert(PI_OSVersion, QString::number(QSysInfo::symbianVersion()); #else - insert(PI_OSName, QLS("Other")); + pi.insert(PI_OSName, QLS("Other")); #endif - QProcess git; - QString cmd; - QStringList args; + QProcess git; + QString cmd; + QStringList args; #if defined(Q_OS_WIN) - cmd = QLS("cmd.exe"); - args << QLS("/c") << QLS("git"); + cmd = QLS("cmd.exe"); + args << QLS("/c") << QLS("git"); #else - cmd = QLS("git"); + cmd = QLS("git"); #endif - args << QLS("log") << QLS("--max-count=1") << QLS("--pretty=%H [%an] [%ad] %s"); - git.start(cmd, args); - git.waitForFinished(3000); - if (!git.exitCode()) - insert(PI_GitCommit, QString::fromLocal8Bit(git.readAllStandardOutput().constData()).simplified()); - else - insert(PI_GitCommit, QLS("Unknown")); - } + args << QLS("log") << QLS("--max-count=1") << QLS("--pretty=%H [%an] [%ad] %s"); + git.start(cmd, args); + git.waitForFinished(3000); + if (!git.exitCode()) + pi.insert(PI_GitCommit, QString::fromLocal8Bit(git.readAllStandardOutput().constData()).simplified()); + else + pi.insert(PI_GitCommit, QLS("Unknown")); QByteArray gb = qgetenv("PULSE_GIT_BRANCH"); if (!gb.isEmpty()) - insert(PI_PulseGitBranch, QString::fromLatin1(gb)); + pi.insert(PI_PulseGitBranch, QString::fromLatin1(gb)); QByteArray tb = qgetenv("PULSE_TESTR_BRANCH"); if (!tb.isEmpty()) - insert(PI_PulseTestrBranch, QString::fromLatin1(tb)); + pi.insert(PI_PulseTestrBranch, QString::fromLatin1(tb)); + + return pi; +} + + +PlatformInfo::PlatformInfo(const PlatformInfo &other) + : QMap<QString, QString>(other) +{ + sigKeys = other.sigKeys; + replaceDefault = other.replaceDefault; +} + + +PlatformInfo &PlatformInfo::operator=(const PlatformInfo &other) +{ + QMap<QString, QString>::operator=(other); + sigKeys = other.sigKeys; + replaceDefault = other.replaceDefault; + return *this; +} + + +void PlatformInfo::addSignificantKeys(const QStringList &keys, bool replaceDefaultKeys) +{ + sigKeys = keys; + replaceDefault = replaceDefaultKeys; +} + + +QStringList PlatformInfo::addedKeys() const +{ + return sigKeys; +} + + +bool PlatformInfo::addedKeysReplaceDefault() const +{ + return replaceDefault; +} + + +QDataStream & operator<< (QDataStream &stream, const PlatformInfo &pi) +{ + stream << static_cast<const QMap<QString, QString>&>(pi); + stream << pi.sigKeys << pi.replaceDefault; + return stream; +} + + +QDataStream & operator>> (QDataStream &stream, PlatformInfo &pi) +{ + stream >> static_cast<QMap<QString, QString>&>(pi); + stream >> pi.sigKeys >> pi.replaceDefault; + return stream; } @@ -251,7 +320,7 @@ void ImageItem::readImageFromStream(QDataStream &in) QDataStream & operator<< (QDataStream &stream, const ImageItem &ii) { - stream << ii.testFunction << ii.itemName << ii.itemChecksum << quint8(ii.status) << ii.imageChecksums; + stream << ii.testFunction << ii.itemName << ii.itemChecksum << quint8(ii.status) << ii.imageChecksums << ii.misc; ii.writeImageToStream(stream); return stream; } @@ -259,7 +328,7 @@ QDataStream & operator<< (QDataStream &stream, const ImageItem &ii) QDataStream & operator>> (QDataStream &stream, ImageItem &ii) { quint8 encStatus; - stream >> ii.testFunction >> ii.itemName >> ii.itemChecksum >> encStatus >> ii.imageChecksums; + stream >> ii.testFunction >> ii.itemName >> ii.itemChecksum >> encStatus >> ii.imageChecksums >> ii.misc; ii.status = ImageItem::ItemStatus(encStatus); ii.readImageFromStream(stream); return stream; @@ -293,7 +362,7 @@ bool BaselineProtocol::connect(const QString &testCase, bool *dryrun) } } - PlatformInfo pi(true); + PlatformInfo pi = PlatformInfo::localHostInfo(); pi.insert(PI_TestCase, testCase); QByteArray block; QDataStream ds(&block, QIODevice::ReadWrite); @@ -453,3 +522,4 @@ QString BaselineProtocol::errorMessage() ret += QLS(" Socket state: ") + socket.errorString(); return ret; } + diff --git a/tests/arthur/common/baselineprotocol.h b/tests/arthur/common/baselineprotocol.h index 259555d..8a99ace 100644 --- a/tests/arthur/common/baselineprotocol.h +++ b/tests/arthur/common/baselineprotocol.h @@ -48,29 +48,49 @@ #include <QVector> #include <QMap> #include <QPointer> +#include <QStringList> #define QLS QLatin1String #define QLC QLatin1Char #define FileFormat "png" -const QString PI_TestCase(QLS("TestCase")); -const QString PI_HostName(QLS("HostName")); -const QString PI_HostAddress(QLS("HostAddress")); -const QString PI_OSName(QLS("OSName")); -const QString PI_OSVersion(QLS("OSVersion")); -const QString PI_QtVersion(QLS("QtVersion")); -const QString PI_BuildKey(QLS("BuildKey")); -const QString PI_GitCommit(QLS("GitCommit")); -const QString PI_QMakeSpec(QLS("QMakeSpec")); -const QString PI_PulseGitBranch(QLS("PulseGitBranch")); -const QString PI_PulseTestrBranch(QLS("PulseTestrBranch")); +extern const QString PI_TestCase; +extern const QString PI_HostName; +extern const QString PI_HostAddress; +extern const QString PI_OSName; +extern const QString PI_OSVersion; +extern const QString PI_QtVersion; +extern const QString PI_BuildKey; +extern const QString PI_GitCommit; +extern const QString PI_QMakeSpec; +extern const QString PI_PulseGitBranch; +extern const QString PI_PulseTestrBranch; class PlatformInfo : public QMap<QString, QString> { public: - PlatformInfo(bool useLocal = false); + PlatformInfo(); + PlatformInfo(const PlatformInfo &other); + ~PlatformInfo() + {} + PlatformInfo &operator=(const PlatformInfo &other); + + static PlatformInfo localHostInfo(); + + void addSignificantKeys(const QStringList& keys, bool replaceDefaultKeys=false); + QStringList addedKeys() const; + bool addedKeysReplaceDefault() const; + +private: + QStringList sigKeys; + bool replaceDefault; + friend QDataStream & operator<< (QDataStream &stream, const PlatformInfo &pi); + friend QDataStream & operator>> (QDataStream &stream, PlatformInfo& pi); }; +QDataStream & operator<< (QDataStream &stream, const PlatformInfo &pi); +QDataStream & operator>> (QDataStream &stream, PlatformInfo& pi); + struct ImageItem { @@ -99,6 +119,7 @@ public: QImage image; QList<quint64> imageChecksums; quint16 itemChecksum; + QByteArray misc; void writeImageToStream(QDataStream &stream) const; void readImageFromStream(QDataStream &stream); @@ -123,7 +144,7 @@ public: // Important constants here // **************************************************** enum Constant { - ProtocolVersion = 4, + ProtocolVersion = 5, ServerPort = 54129, Timeout = 5000 }; diff --git a/tests/arthur/common/paintcommands.cpp b/tests/arthur/common/paintcommands.cpp index b00ce81..7a018e3 100644 --- a/tests/arthur/common/paintcommands.cpp +++ b/tests/arthur/common/paintcommands.cpp @@ -96,6 +96,13 @@ const char *PaintCommands::fontWeightTable[] = { "Black" }; +const char *PaintCommands::fontHintingTable[] = { + "Default", + "None", + "Vertical", + "Full" +}; + const char *PaintCommands::clipOperationTable[] = { "NoClip", "ReplaceClip", @@ -177,8 +184,9 @@ const char *PaintCommands::imageFormatTable[] = { int PaintCommands::translateEnum(const char *table[], const QString &pattern, int limit) { + QByteArray p = pattern.toLatin1().toLower(); for (int i=0; i<limit; ++i) - if (pattern.toLower() == QString(QLatin1String(table[i])).toLower()) + if (p == QByteArray::fromRawData(table[i], qstrlen(table[i])).toLower()) return i; return -1; } @@ -287,9 +295,9 @@ void PaintCommands::staticInit() "setCompositionMode <composition mode enum>", "setCompositionMode SourceOver"); DECL_PAINTCOMMAND("setFont", command_setFont, - "^setFont\\s+\"([\\w\\s]*)\"\\s*(\\w*)\\s*(\\w*)\\s*(\\w*)$", - "setFont <fontFace> [size] [font weight|font weight enum] [italic]\n - font weight is an integer between 0 and 99", - "setFont \"times\" normal"); + "^setFont\\s+\"([\\w\\s]*)\"\\s*(\\w*)\\s*(\\w*)\\s*(\\w*)\\s*(\\w*)$", + "setFont <fontFace> [size] [font weight|font weight enum] [italic] [hinting enum]\n - font weight is an integer between 0 and 99", + "setFont \"times\" 12"); DECL_PAINTCOMMAND("setPen", command_setPen, "^setPen\\s+#?(\\w*)$", "setPen <color>\nsetPen <pen style enum>\nsetPen brush", @@ -641,6 +649,7 @@ void PaintCommands::staticInit() ADD_ENUMLIST("brush styles", brushStyleTable); ADD_ENUMLIST("pen styles", penStyleTable); ADD_ENUMLIST("font weights", fontWeightTable); + ADD_ENUMLIST("font hintings", fontHintingTable); ADD_ENUMLIST("clip operations", clipOperationTable); ADD_ENUMLIST("spread methods", spreadMethodTable); ADD_ENUMLIST("composition modes", compositionModeTable); @@ -2061,11 +2070,22 @@ void PaintCommands::command_setFont(QRegExp re) bool italic = caps.at(4).toLower() == "true" || caps.at(4).toLower() == "italic"; + QFont font(family, size, weight, italic); + +#if QT_VERSION >= 0x040800 + int hinting = translateEnum(fontHintingTable, caps.at(5), 4); + if (hinting == -1) + hinting = 0; + else + font.setHintingPreference(QFont::HintingPreference(hinting)); +#else + int hinting = 1; +#endif if (m_verboseMode) - printf(" -(lance) setFont(family=%s, size=%d, weight=%d, italic=%d\n", - qPrintable(family), size, weight, italic); + printf(" -(lance) setFont(family=%s, size=%d, weight=%d, italic=%d hinting=%s\n", + qPrintable(family), size, weight, italic, fontHintingTable[hinting]); - m_painter->setFont(QFont(family, size, weight, italic)); + m_painter->setFont(font); } /***************************************************************************************************/ diff --git a/tests/arthur/common/paintcommands.h b/tests/arthur/common/paintcommands.h index b2516e1..2740412 100644 --- a/tests/arthur/common/paintcommands.h +++ b/tests/arthur/common/paintcommands.h @@ -290,6 +290,7 @@ private: static const char *brushStyleTable[]; static const char *penStyleTable[]; static const char *fontWeightTable[]; + static const char *fontHintingTable[]; static const char *clipOperationTable[]; static const char *spreadMethodTable[]; static const char *coordinateMethodTable[]; diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml index 8addcb9..6467c42 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 MyQmlObject { - onArgumentSignal: setString('pass ' + a + ' ' + b + ' ' + c) + onArgumentSignal: setString('pass ' + a + ' ' + b + ' ' + c + ' ' + d + ' ' + e) } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml index ffbe317..4fc2dab 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml @@ -7,10 +7,12 @@ MyQmlObject property real realProperty property color colorProperty property variant variantProperty + property int enumProperty + property int qtEnumProperty - signal mySignal(int a, real b, color c, variant d) + signal mySignal(int a, real b, color c, variant d, int e, int f) - onMySignal: { intProperty = a; realProperty = b; colorProperty = c; variantProperty = d; } + onMySignal: { intProperty = a; realProperty = b; colorProperty = c; variantProperty = d; enumProperty = e; qtEnumProperty = f; } - onBasicSignal: root.mySignal(10, 19.2, Qt.rgba(1, 1, 0, 1), Qt.rgba(1, 0, 1, 1)) + onBasicSignal: root.mySignal(10, 19.2, Qt.rgba(1, 1, 0, 1), Qt.rgba(1, 0, 1, 1), MyQmlObject.EnumValue3, Qt.LeftButton) } diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp index 7e63bd5..1d65b15 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp @@ -127,6 +127,8 @@ void registerTypes() qmlRegisterType<QPlainTextEdit>("Qt.test",1,0,"QPlainTextEdit"); qRegisterMetaType<MyQmlObject::MyType>("MyQmlObject::MyType"); + qRegisterMetaType<MyQmlObject::MyType>("MyEnum2"); + qRegisterMetaType<Qt::MouseButtons>("Qt::MouseButtons"); } #include "testtypes.moc" diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index 081cc4c..94cec3f 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -159,7 +159,7 @@ public: signals: void basicSignal(); - void argumentSignal(int a, QString b, qreal c); + void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e); void stringChanged(); void objectChanged(); void anotherBasicSignal(); diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index f913ab8..3b3ca6a 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -305,8 +305,8 @@ void tst_qdeclarativeecmascript::signalAssignment() MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->string(), QString()); - emit object->argumentSignal(19, "Hello world!", 10.25); - QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25")); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25 3 2")); } } @@ -871,7 +871,7 @@ void tst_qdeclarativeecmascript::scope() QCOMPARE(object->property("test").toInt(), 0); QCOMPARE(object->property("test2").toString(), QString()); - emit object->argumentSignal(13, "Argument Scope", 9); + emit object->argumentSignal(13, "Argument Scope", 9, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("test").toInt(), 13); QCOMPARE(object->property("test2").toString(), QString("Argument Scope")); @@ -896,6 +896,8 @@ void tst_qdeclarativeecmascript::signalParameterTypes() QCOMPARE(object->property("realProperty").toReal(), 19.2); QVERIFY(object->property("colorProperty").value<QColor>() == QColor(255, 255, 0, 255)); QVERIFY(object->property("variantProperty") == QVariant::fromValue(QColor(255, 0, 255, 255))); + QVERIFY(object->property("enumProperty") == MyQmlObject::EnumValue3); + QVERIFY(object->property("qtEnumProperty") == Qt::LeftButton); } /* @@ -1140,7 +1142,7 @@ void tst_qdeclarativeecmascript::signalTriggeredBindings() QCOMPARE(object->property("test1").toReal(), 200.); QCOMPARE(object->property("test2").toReal(), 200.); - object->argumentSignal(10, QString(), 10); + object->argumentSignal(10, QString(), 10, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("base").toReal(), 400.); QCOMPARE(object->property("test1").toReal(), 400.); @@ -1941,7 +1943,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toBool(), false); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("test").toBool(), true); delete object; @@ -1954,7 +1956,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toBool(), false); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("test").toBool(), true); delete object; @@ -1967,7 +1969,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toBool(), false); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("test").toBool(), true); delete object; @@ -1980,7 +1982,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->methodCalled(), false); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->methodCalled(), true); delete object; @@ -1993,7 +1995,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->methodCalled(), false); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->methodCalled(), true); delete object; @@ -2006,7 +2008,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 0); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("test").toInt(), 2); delete object; @@ -2022,13 +2024,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 0); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("test").toInt(), 1); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("test").toInt(), 2); emit object->basicSignal(); QCOMPARE(object->property("test").toInt(), 2); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("test").toInt(), 2); delete object; @@ -2041,13 +2043,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 0); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("test").toInt(), 1); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("test").toInt(), 2); emit object->basicSignal(); QCOMPARE(object->property("test").toInt(), 2); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("test").toInt(), 2); delete object; @@ -2060,13 +2062,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 0); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("test").toInt(), 1); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("test").toInt(), 2); emit object->basicSignal(); QCOMPARE(object->property("test").toInt(), 2); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("test").toInt(), 3); delete object; @@ -2078,13 +2080,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 0); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("test").toInt(), 1); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("test").toInt(), 2); emit object->basicSignal(); QCOMPARE(object->property("test").toInt(), 2); - emit object->argumentSignal(19, "Hello world!", 10.25); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); QCOMPARE(object->property("test").toInt(), 3); delete object; diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index d499edf..4fa1cb3 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -110,7 +110,7 @@ void tst_qdeclarativeflickable::create() QCOMPARE(obj->isInteractive(), true); QCOMPARE(obj->boundsBehavior(), QDeclarativeFlickable::DragAndOvershootBounds); QCOMPARE(obj->pressDelay(), 0); - QCOMPARE(obj->maximumFlickVelocity(), 2000.); + QCOMPARE(obj->maximumFlickVelocity(), 2500.); delete obj; } diff --git a/tests/auto/declarative/qdeclarativeimage/data/aspectratio.qml b/tests/auto/declarative/qdeclarativeimage/data/aspectratio.qml index 739299d..cd092bc 100644 --- a/tests/auto/declarative/qdeclarativeimage/data/aspectratio.qml +++ b/tests/auto/declarative/qdeclarativeimage/data/aspectratio.qml @@ -1,6 +1,10 @@ import QtQuick 1.0 Image { + property int widthChange: 0 + property int heightChange: 0 source: "heart.png" fillMode: Image.PreserveAspectFit; + onWidthChanged: widthChange += 1 + onHeightChanged: heightChange += 1 } diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index 9e090d2..87e3347 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -91,6 +91,7 @@ private slots: void sourceSize_QTBUG_14303(); void sourceSize_QTBUG_16389(); void nullPixmapPaint(); + void resetSourceSize(); void testQtQuick11Attributes(); void testQtQuick11Attributes_data(); @@ -247,14 +248,22 @@ void tst_qdeclarativeimage::preserveAspectRatio() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/aspectratio.qml")); QDeclarativeImage *image = qobject_cast<QDeclarativeImage*>(canvas->rootObject()); QVERIFY(image != 0); + QCOMPARE(image->property("widthChange").toInt(), 1); + QCOMPARE(image->property("heightChange").toInt(), 1); image->setWidth(80.0); + QCOMPARE(image->property("widthChange").toInt(), 2); + QCOMPARE(image->property("heightChange").toInt(), 2); QCOMPARE(image->width(), 80.); QCOMPARE(image->height(), 80.); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/aspectratio.qml")); image = qobject_cast<QDeclarativeImage*>(canvas->rootObject()); - image->setHeight(60.0); QVERIFY(image != 0); + QCOMPARE(image->property("widthChange").toInt(), 1); + QCOMPARE(image->property("heightChange").toInt(), 1); + image->setHeight(60.0); + QCOMPARE(image->property("widthChange").toInt(), 2); + QCOMPARE(image->property("heightChange").toInt(), 2); QCOMPARE(image->height(), 60.); QCOMPARE(image->width(), 60.); delete canvas; @@ -693,6 +702,27 @@ void tst_qdeclarativeimage::nullPixmapPaint() delete image; } +void tst_qdeclarativeimage::resetSourceSize() +{ + QString src = QUrl::fromLocalFile(SRCDIR "/data/heart200.png").toString(); + QString componentStr = "import QtQuick 1.1\nImage { function reset() { sourceSize = undefined }\nsource: \"" + src + "\"; sourceSize: Qt.size(100,100) }"; + + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeImage *obj = qobject_cast<QDeclarativeImage*>(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->pixmap().width(), 100); + QCOMPARE(obj->pixmap().height(), 100); + QCOMPARE(obj->sourceSize().height(), 100); + QCOMPARE(obj->sourceSize().width(), 100); + + QMetaObject::invokeMethod(obj, "reset"); + QCOMPARE(obj->pixmap().width(), 200); + QCOMPARE(obj->pixmap().height(), 200); + QCOMPARE(obj->sourceSize().height(), 200); + QCOMPARE(obj->sourceSize().width(), 200); +} + void tst_qdeclarativeimage::testQtQuick11Attributes() { QFETCH(QString, code); diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 5a2591f..2ce493b 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -174,7 +174,7 @@ private: QVERIFY(component.errors().isEmpty()); \ } else { \ QFile file(QLatin1String(SRCDIR) + QLatin1String("/data/") + QLatin1String(errorfile)); \ - QVERIFY(file.open(QIODevice::ReadOnly)); \ + QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \ QByteArray data = file.readAll(); \ file.close(); \ QList<QByteArray> expected = data.split('\n'); \ diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index 45072f3..2f7513f 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -106,6 +106,7 @@ private slots: void property_changes_data(); void property_changes_worker(); void property_changes_worker_data(); + void clear(); }; int tst_qdeclarativelistmodel::roleFromName(const QDeclarativeListModel *model, const QString &roleName) { @@ -1091,6 +1092,47 @@ void tst_qdeclarativelistmodel::property_changes_worker_data() property_changes_data(); } +void tst_qdeclarativelistmodel::clear() +{ + QDeclarativeEngine engine; + QDeclarativeListModel model; + QDeclarativeEngine::setContextForObject(&model, engine.rootContext()); + engine.rootContext()->setContextObject(&model); + + QScriptEngine *seng = QDeclarativeEnginePrivate::getScriptEngine(&engine); + QScriptValue sv = seng->newObject(); + QVariant result; + + model.clear(); + QCOMPARE(model.count(), 0); + + sv.setProperty("propertyA", "value a"); + sv.setProperty("propertyB", "value b"); + model.append(sv); + QCOMPARE(model.count(), 1); + + model.clear(); + QCOMPARE(model.count(), 0); + + model.append(sv); + model.append(sv); + QCOMPARE(model.count(), 2); + + model.clear(); + QCOMPARE(model.count(), 0); + + // clearing does not remove the roles + sv.setProperty("propertyC", "value c"); + model.append(sv); + QList<int> roles = model.roles(); + model.clear(); + QCOMPARE(model.count(), 0); + QCOMPARE(model.roles(), roles); + QCOMPARE(model.toString(roles[0]), QString("propertyA")); + QCOMPARE(model.toString(roles[1]), QString("propertyB")); + QCOMPARE(model.toString(roles[2]), QString("propertyC")); +} + QTEST_MAIN(tst_qdeclarativelistmodel) #include "tst_qdeclarativelistmodel.moc" diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp index dc104e2..9d1c609 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp @@ -85,7 +85,7 @@ private slots: QVERIFY(component.errors().isEmpty()); \ } else { \ QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \ - QVERIFY(file.open(QIODevice::ReadOnly)); \ + QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \ QByteArray data = file.readAll(); \ file.close(); \ QList<QByteArray> expected = data.split('\n'); \ diff --git a/tests/auto/declarative/qdeclarativepincharea/data/flickresize.qml b/tests/auto/declarative/qdeclarativepincharea/data/flickresize.qml new file mode 100644 index 0000000..2da58fc --- /dev/null +++ b/tests/auto/declarative/qdeclarativepincharea/data/flickresize.qml @@ -0,0 +1,50 @@ +import QtQuick 1.1 + +Flickable { + id: flick + property real scale: 1.0 + width: 640 + height: 360 + contentWidth: 500 + contentHeight: 500 + + PinchArea { + objectName: "pincharea" + width: Math.max(flick.contentWidth, flick.width) + height: Math.max(flick.contentHeight, flick.height) + + property real initialWidth + property real initialHeight + onPinchStarted: { + initialWidth = flick.contentWidth + initialHeight = flick.contentHeight + } + + onPinchUpdated: { + // adjust content pos due to drag + flick.contentX += pinch.previousCenter.x - pinch.center.x + flick.contentY += pinch.previousCenter.y - pinch.center.y + + // resize content + flick.resizeContent(initialWidth * pinch.scale, initialHeight * pinch.scale, pinch.center) + flick.scale = pinch.scale + } + + onPinchFinished: { + // Move its content within bounds. + flick.returnToBounds() + } + + Rectangle { + width: flick.contentWidth + height: flick.contentHeight + color: "white" + Rectangle { + anchors.centerIn: parent + width: parent.width-40 + height: parent.height-40 + color: "blue" + } + } + } +} diff --git a/tests/auto/declarative/qdeclarativepincharea/tst_qdeclarativepincharea.cpp b/tests/auto/declarative/qdeclarativepincharea/tst_qdeclarativepincharea.cpp index f175033..90506ba 100644 --- a/tests/auto/declarative/qdeclarativepincharea/tst_qdeclarativepincharea.cpp +++ b/tests/auto/declarative/qdeclarativepincharea/tst_qdeclarativepincharea.cpp @@ -43,6 +43,7 @@ #include <QtTest/QSignalSpy> #include <private/qdeclarativepincharea_p.h> #include <private/qdeclarativerectangle_p.h> +#include <private/qdeclarativeflickable_p.h> #include <QtDeclarative/qdeclarativeview.h> #include <QtDeclarative/qdeclarativecontext.h> @@ -58,6 +59,7 @@ private slots: void pinchProperties(); void scale(); void pan(); + void flickable(); private: QDeclarativeView *createView(); @@ -301,6 +303,77 @@ void tst_QDeclarativePinchArea::pan() delete canvas; } +void tst_QDeclarativePinchArea::flickable() +{ + QDeclarativeView *canvas = createView(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickresize.qml")); + canvas->show(); + canvas->setFocus(); + QTest::qWaitForWindowShown(canvas); + QVERIFY(canvas->rootObject() != 0); + qApp->processEvents(); + + QDeclarativePinchArea *pinchArea = canvas->rootObject()->findChild<QDeclarativePinchArea*>("pincharea"); + QDeclarativePinch *pinch = pinchArea->pinch(); + QVERIFY(pinchArea != 0); + QVERIFY(pinch != 0); + + QDeclarativeFlickable *root = qobject_cast<QDeclarativeFlickable*>(canvas->rootObject()); + QVERIFY(root != 0); + + QWidget *vp = canvas->viewport(); + + QPoint p1(110, 80); + QPoint p2(100, 100); + + // begin by moving one touch point (mouse) + QTest::mousePress(vp, Qt::LeftButton, 0, canvas->mapFromScene(p1)); + QTest::touchEvent(vp).press(0, p1); + { + p1 -= QPoint(10,10); + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(p1), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + QTest::touchEvent(vp).move(0, p1); + } + { + p1 -= QPoint(10,10); + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(p1), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(vp, &mv); + QTest::touchEvent(vp).move(0, p1); + } + { + p1 -= QPoint(10,10); + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(p1), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(vp, &mv); + QTest::touchEvent(vp).move(0, p1); + } + + // Flickable has reacted to the gesture + QVERIFY(root->isMoving()); + QVERIFY(root->property("scale").toReal() == 1.0); + + // add another touch point and continue moving + QTest::touchEvent(vp).stationary(0).press(1, p2); + p1 -= QPoint(10,10); + p2 += QPoint(10,10); + QTest::touchEvent(vp).move(0, p1).move(1, p2); + + QCOMPARE(root->property("scale").toReal(), 1.0); + + p1 -= QPoint(10,10); + p2 += QPoint(10,10); + QTest::touchEvent(vp).move(0, p1).move(1, p2); + + // PinchArea has stolen the gesture. + QVERIFY(!root->isMoving()); + QVERIFY(root->property("scale").toReal() > 1.0); + + QTest::mouseRelease(vp, Qt::LeftButton, 0, canvas->mapFromScene(p1)); + QTest::touchEvent(vp).release(0, p1).release(1, p2); + + delete canvas; +} + QDeclarativeView *tst_QDeclarativePinchArea::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index 92ab722..78821cb 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -154,6 +154,15 @@ void tst_QDeclarativePositioners::test_horizontal_rtl() QCOMPARE(row->width(), 110.0); QCOMPARE(row->height(), 50.0); + // Change the width of the row and check that items stay to the right + row->setWidth(200); + QCOMPARE(one->x(), 150.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 130.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 90.0); + QCOMPARE(three->y(), 0.0); + delete canvas; } @@ -527,6 +536,19 @@ void tst_QDeclarativePositioners::test_grid_rightToLeft() QCOMPARE(grid->width(), 100.0); QCOMPARE(grid->height(), 100.0); + // Change the width of the grid and check that items stay to the right + grid->setWidth(200); + QCOMPARE(one->x(), 150.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 130.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 100.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 150.0); + QCOMPARE(four->y(), 50.0); + QCOMPARE(five->x(), 140.0); + QCOMPARE(five->y(), 50.0); + delete canvas; } diff --git a/tests/auto/declarative/qdeclarativetextedit/data/CursorRect.qml b/tests/auto/declarative/qdeclarativetextedit/data/CursorRect.qml new file mode 100644 index 0000000..3af0313 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/CursorRect.qml @@ -0,0 +1,8 @@ +import QtQuick 1.0 + +TextEdit { + focus: true + objectName: "myEdit" + width: 50 + text: "This is a long piece of text" +} diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index f62c2c5..8f1be6f 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -148,6 +148,7 @@ private slots: void preeditMicroFocus(); void inputContextMouseHandler(); void inputMethodComposing(); + void cursorRectangleSize(); private: void simulateKey(QDeclarativeView *, int key, Qt::KeyboardModifiers modifiers = 0); @@ -1340,6 +1341,12 @@ void tst_qdeclarativetextedit::mouseSelection() else QVERIFY(str.isEmpty()); + // Clicking and shift to clicking between the same points should select the same text. + textEditObject->setCursorPosition(0); + QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::NoModifier, canvas->mapFromScene(QPoint(x1,y))); + QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::ShiftModifier, canvas->mapFromScene(QPoint(x2,y))); + QCOMPARE(textEditObject->selectedText(), str); + delete canvas; } @@ -1436,6 +1443,12 @@ void tst_qdeclarativetextedit::mouseSelectionMode() QVERIFY(str != text); } + // Clicking and shift to clicking between the same points should select the same text. + textEditObject->setCursorPosition(0); + QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::NoModifier, canvas->mapFromScene(QPoint(x1,y))); + QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::ShiftModifier, canvas->mapFromScene(QPoint(x2,y))); + QCOMPARE(textEditObject->selectedText(), str); + delete canvas; } @@ -2409,6 +2422,25 @@ void tst_qdeclarativetextedit::inputMethodComposing() QCOMPARE(spy.count(), 2); } +void tst_qdeclarativetextedit::cursorRectangleSize() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/CursorRect.qml"); + QVERIFY(canvas->rootObject() != 0); + canvas->show(); + canvas->setFocus(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + + QDeclarativeTextEdit *textEdit = qobject_cast<QDeclarativeTextEdit *>(canvas->rootObject()); + QVERIFY(textEdit != 0); + textEdit->setFocus(Qt::OtherFocusReason); + QRectF cursorRect = textEdit->positionToRectangle(textEdit->cursorPosition()); + QRectF microFocusFromScene = canvas->scene()->inputMethodQuery(Qt::ImMicroFocus).toRectF(); + QRectF microFocusFromApp= QApplication::focusWidget()->inputMethodQuery(Qt::ImMicroFocus).toRectF(); + + QCOMPARE(microFocusFromScene.size(), cursorRect.size()); + QCOMPARE(microFocusFromApp.size(), cursorRect.size()); +} QTEST_MAIN(tst_qdeclarativetextedit) #include "tst_qdeclarativetextedit.moc" diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 45f38a4..ef32ee3 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -135,6 +135,7 @@ private slots: void preeditMicroFocus(); void inputContextMouseHandler(); void inputMethodComposing(); + void cursorRectangleSize(); private: void simulateKey(QDeclarativeView *, int key); @@ -604,10 +605,8 @@ void tst_qdeclarativetextinput::moveCursorSelection_data() << standard[2] << 13 << 6 << QDeclarativeTextInput::SelectWords << 6 << 13 << false; QTest::newRow("Hello<(, world!)>|words") << standard[2] << 5 << 13 << QDeclarativeTextInput::SelectWords << 5 << 13 << true; - // Fails due to an issue with QTextBoundaryFinder and punctuation at the end of strings. - // QTBUG-11365 - // QTest::newRow("world<(!)>|words") - // << standard[2] << 12 << 13 << QDeclarativeTextInput::SelectWords << 12 << 13 << true; + QTest::newRow("world<(!)>|words") + << standard[2] << 12 << 13 << QDeclarativeTextInput::SelectWords << 12 << 13 << true; QTest::newRow("world!<()>)|words") << standard[2] << 13 << 13 << QDeclarativeTextInput::SelectWords << 13 << 13 << true; QTest::newRow("world<()>!)|words") @@ -653,16 +652,15 @@ void tst_qdeclarativetextinput::moveCursorSelection_data() QTest::newRow(" <s(pac)ey> text |words") << standard[4] << 1 << 4 << QDeclarativeTextInput::SelectWords << 1 << 7 << true; QTest::newRow(" spacey <t(ex)t> |words") - << standard[4] << 11 << 13 << QDeclarativeTextInput::SelectWords << 10 << 14 << false; // Should be reversible. QTBUG-11365 + << standard[4] << 11 << 13 << QDeclarativeTextInput::SelectWords << 10 << 14 << true; QTest::newRow("<( )>spacey text |words|ltr") << standard[4] << 0 << 1 << QDeclarativeTextInput::SelectWords << 0 << 1 << false; QTest::newRow("<( )spacey> text |words|rtl") << standard[4] << 1 << 0 << QDeclarativeTextInput::SelectWords << 0 << 7 << false; QTest::newRow("spacey <text( )>|words|ltr") << standard[4] << 14 << 15 << QDeclarativeTextInput::SelectWords << 10 << 15 << false; -// QTBUG-11365 -// QTest::newRow("spacey text<( )>|words|rtl") -// << standard[4] << 15 << 14 << QDeclarativeTextInput::SelectWords << 14 << 15 << false; + QTest::newRow("spacey text<( )>|words|rtl") + << standard[4] << 15 << 14 << QDeclarativeTextInput::SelectWords << 14 << 15 << false; QTest::newRow("<()> spacey text |words") << standard[4] << 0 << 0 << QDeclarativeTextInput::SelectWords << 0 << 0 << false; QTest::newRow(" spacey text <()>|words") @@ -857,23 +855,21 @@ void tst_qdeclarativetextinput::moveCursorSelectionSequence_data() << 15 << 12 << 15 << 10 << 15 << 15 << 15; -// QTBUG-11365 -// QTest::newRow(" spacey <te(xt{^ )>}|rtl") -// << standard[4] -// << 15 << 12 << 14 -// << 10 << 15 -// << 14 << 15; + QTest::newRow(" spacey <te(xt{^ )>}|rtl") + << standard[4] + << 15 << 12 << 14 + << 10 << 15 + << 14 << 15; QTest::newRow(" spacey {<te(x^t} )>|ltr") << standard[4] << 12 << 15 << 13 << 10 << 15 << 10 << 14; -// QTBUG-11365 -// QTest::newRow(" spacey {<te(xt^} )>|ltr") -// << standard[4] -// << 12 << 15 << 14 -// << 10 << 15 -// << 10 << 14; + QTest::newRow(" spacey {<te(xt^} )>|ltr") + << standard[4] + << 12 << 15 << 14 + << 10 << 15 + << 10 << 14; } void tst_qdeclarativetextinput::moveCursorSelectionSequence() @@ -1633,12 +1629,11 @@ void tst_qdeclarativetextinput::cursorDelegate() //Test Delegate gets moved for(int i=0; i<= textInputObject->text().length(); i++){ textInputObject->setCursorPosition(i); - //+5 is because the TextInput cursorRectangle is just a 10xHeight area centered on cursor position - QCOMPARE(textInputObject->cursorRectangle().x() + 5, qRound(delegateObject->x())); + QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x())); QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); } textInputObject->setCursorPosition(0); - QCOMPARE(textInputObject->cursorRectangle().x()+5, qRound(delegateObject->x())); + QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x())); QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); //Test Delegate gets deleted textInputObject->setCursorDelegate(0); @@ -1727,19 +1722,26 @@ void tst_qdeclarativetextinput::cursorRectangle() QRect r; + // some tolerance for different fonts. +#ifdef Q_OS_LINUX + const int error = 2; +#else + const int error = 5; +#endif + for (int i = 0; i <= 5; ++i) { input.setCursorPosition(i); r = input.cursorRectangle(); int textWidth = fm.width(text.mid(0, i)); - QVERIFY(r.left() < textWidth); - QVERIFY(r.right() > textWidth); + QVERIFY(r.left() < textWidth + error); + QVERIFY(r.right() > textWidth - error); QCOMPARE(input.inputMethodQuery(Qt::ImMicroFocus).toRect(), r); } // Check the cursor rectangle remains within the input bounding rect when auto scrolling. QVERIFY(r.left() < input.boundingRect().width()); - QVERIFY(r.right() >= input.width()); + QVERIFY(r.right() >= input.width() - error); for (int i = 6; i < text.length(); ++i) { input.setCursorPosition(i); @@ -2240,18 +2242,25 @@ void tst_qdeclarativetextinput::preeditAutoScroll() QCOMPARE(input.positionAt(0), 0); QCOMPARE(input.positionAt(input.width()), 5); + // some tolerance for different fonts. +#ifdef Q_OS_LINUX + const int error = 2; +#else + const int error = 5; +#endif + // test if the preedit is larger than the text input that the // character preceding the cursor is still visible. qreal x = input.positionToRectangle(0).x(); for (int i = 0; i < 3; ++i) { ic.sendPreeditText(preeditText, i + 1); - QVERIFY(input.cursorRectangle().right() >= fm.width(preeditText.at(i))); + QVERIFY(input.cursorRectangle().right() >= fm.width(preeditText.at(i)) - error); QVERIFY(input.positionToRectangle(0).x() < x); x = input.positionToRectangle(0).x(); } for (int i = 1; i >= 0; --i) { ic.sendPreeditText(preeditText, i + 1); - QVERIFY(input.cursorRectangle().right() >= fm.width(preeditText.at(i))); + QVERIFY(input.cursorRectangle().right() >= fm.width(preeditText.at(i)) - error); QVERIFY(input.positionToRectangle(0).x() > x); x = input.positionToRectangle(0).x(); } @@ -2489,6 +2498,26 @@ void tst_qdeclarativetextinput::inputMethodComposing() QCOMPARE(spy.count(), 2); } +void tst_qdeclarativetextinput::cursorRectangleSize() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/positionAt.qml"); + QVERIFY(canvas->rootObject() != 0); + canvas->show(); + canvas->setFocus(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + + QDeclarativeTextInput *textInput = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject()); + QVERIFY(textInput != 0); + textInput->setFocus(Qt::OtherFocusReason); + QRectF cursorRect = textInput->positionToRectangle(textInput->cursorPosition()); + QRectF microFocusFromScene = canvas->scene()->inputMethodQuery(Qt::ImMicroFocus).toRectF(); + QRectF microFocusFromApp= QApplication::focusWidget()->inputMethodQuery(Qt::ImMicroFocus).toRectF(); + + QCOMPARE(microFocusFromScene.size(), cursorRect.size()); + QCOMPARE(microFocusFromApp.size(), cursorRect.size()); +} + QTEST_MAIN(tst_qdeclarativetextinput) #include "tst_qdeclarativetextinput.moc" diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index af54008..a0e2547 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -418,7 +418,7 @@ void tst_qdeclarativexmllistmodel::headers() QTRY_COMPARE(model->status(), QDeclarativeXmlListModel::Ready); QVariantMap expectedHeaders; - expectedHeaders["Accept"] = "application/xml"; + expectedHeaders["Accept"] = "application/xml,*/*"; QCOMPARE(factory.lastSentHeaders.count(), expectedHeaders.count()); foreach (const QString &header, expectedHeaders.keys()) { diff --git a/tests/auto/lancelot/scripts/hinting.qps b/tests/auto/lancelot/scripts/hinting.qps new file mode 100644 index 0000000..7ce21b2 --- /dev/null +++ b/tests/auto/lancelot/scripts/hinting.qps @@ -0,0 +1,26 @@ +translate 10 50 +setFont "sansserif" 10 +drawText 0 0 "Default hinting:" +setFont "times" 12 normal normal default +drawText 0 20 "The quick brown fox jumps over the lazy dog" + +translate 0 50 +setFont "sansserif" 10 +drawText 0 0 "No hinting:" +setFont "times" 12 normal normal none +drawText 0 20 "The quick brown fox jumps over the lazy dog" + +translate 0 50 +setFont "sansserif" 10 +drawText 0 0 "Vertical hinting:" +setFont "times" 12 normal normal vertical +drawText 0 20 "The quick brown fox jumps over the lazy dog" + +translate 0 50 +setFont "sansserif" 10 +drawText 0 0 "Full hinting:" +setFont "times" 12 normal normal full +drawText 0 20 "The quick brown fox jumps over the lazy dog" + + +# Note: there is also the textlayout_draw command which might be interesting here. diff --git a/tests/auto/lancelot/tst_lancelot.cpp b/tests/auto/lancelot/tst_lancelot.cpp index e515c48..9721665 100644 --- a/tests/auto/lancelot/tst_lancelot.cpp +++ b/tests/auto/lancelot/tst_lancelot.cpp @@ -239,11 +239,20 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format) QSKIP("Blacklisted by baseline server.", SkipSingle); ImageItem rendered = render(baseline, engine, format); + static int consecutiveErrs = 0; if (rendered.image.isNull()) { // Assume an error in the test environment, not Qt QWARN("Error: Failed to render image."); - QSKIP("Aborted due to errors.", SkipSingle); + if (++consecutiveErrs < 3) { + QSKIP("Aborted due to errors.", SkipSingle); + } else { + consecutiveErrs = 0; + QSKIP("Too many errors, skipping rest of testfunction.", SkipAll); + } + } else { + consecutiveErrs = 0; } + if (baseline.status == ImageItem::BaselineNotFound) { proto.submitNewBaseline(rendered, 0); QSKIP("Baseline not found; new baseline created.", SkipSingle); diff --git a/tests/auto/macnativeevents/tst_macnativeevents.cpp b/tests/auto/macnativeevents/tst_macnativeevents.cpp index 3dc0506..9c18a3c 100644 --- a/tests/auto/macnativeevents/tst_macnativeevents.cpp +++ b/tests/auto/macnativeevents/tst_macnativeevents.cpp @@ -69,7 +69,7 @@ private slots: void testMouseEnter(); void testChildDialogInFrontOfModalParent(); #ifdef QT_MAC_USE_COCOA - void testChildWindowInFrontOfParentWindow(); +// void testChildWindowInFrontOfParentWindow(); // void testChildToolWindowInFrontOfChildNormalWindow(); void testChildWindowInFrontOfStaysOnTopParentWindow(); #endif @@ -319,6 +319,11 @@ void tst_MacNativeEvents::testChildDialogInFrontOfModalParent() } #ifdef QT_MAC_USE_COCOA +#if 0 +// This test is disabled as of Qt-4.7.4 because we cannot do it +// unless we use the Cocoa sub window API. But using that opens up +// a world of side effects that we cannot live with. So we rather +// not support child-on-top-of-parent instead. void tst_MacNativeEvents::testChildWindowInFrontOfParentWindow() { // Test that a child window always stacks in front of its parent window. @@ -343,6 +348,7 @@ void tst_MacNativeEvents::testChildWindowInFrontOfParentWindow() QTest::qWait(100); QVERIFY(!child.isVisible()); } +#endif /* This test can be enabled once setStackingOrder has been fixed in qwidget_mac.mm void tst_MacNativeEvents::testChildToolWindowInFrontOfChildNormalWindow() diff --git a/tests/auto/qdir/qdir.pro b/tests/auto/qdir/qdir.pro index 472e646..384c048 100644 --- a/tests/auto/qdir/qdir.pro +++ b/tests/auto/qdir/qdir.pro @@ -4,7 +4,7 @@ RESOURCES += qdir.qrc QT = core wince*|symbian { - DirFiles.files = testdir testdata searchdir resources entrylist types tst_qdir.cpp + DirFiles.files = testdir testData searchdir resources entrylist types tst_qdir.cpp DirFiles.path = . DEPLOYMENT += DirFiles } diff --git a/tests/auto/qdiriterator/tst_qdiriterator.cpp b/tests/auto/qdiriterator/tst_qdiriterator.cpp index bdf0c3b..3691a90 100644 --- a/tests/auto/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/qdiriterator/tst_qdiriterator.cpp @@ -126,6 +126,7 @@ private slots: void uncPaths_data(); void uncPaths(); #endif + void qtbug15421_hiddenDirs_hiddenFiles(); }; tst_QDirIterator::tst_QDirIterator() @@ -173,6 +174,20 @@ tst_QDirIterator::tst_QDirIterator() createLink("nothing", "entrylist/brokenlink.lnk"); # endif #endif + + createDirectory("qtbug15421_hiddenDirs_hiddenFiles"); + createFile("qtbug15421_hiddenDirs_hiddenFiles/normalFile"); + createFile("qtbug15421_hiddenDirs_hiddenFiles/.hiddenFile"); + createDirectory("qtbug15421_hiddenDirs_hiddenFiles/normalDirectory"); + createDirectory("qtbug15421_hiddenDirs_hiddenFiles/.hiddenDirectory"); + createFile("qtbug15421_hiddenDirs_hiddenFiles/normalDirectory/normalFile"); + createFile("qtbug15421_hiddenDirs_hiddenFiles/normalDirectory/.hiddenFile"); + createFile("qtbug15421_hiddenDirs_hiddenFiles/.hiddenDirectory/normalFile"); + createFile("qtbug15421_hiddenDirs_hiddenFiles/.hiddenDirectory/.hiddenFile"); + createDirectory("qtbug15421_hiddenDirs_hiddenFiles/normalDirectory/normalDirectory"); + createDirectory("qtbug15421_hiddenDirs_hiddenFiles/normalDirectory/.hiddenDirectory"); + createDirectory("qtbug15421_hiddenDirs_hiddenFiles/.hiddenDirectory/normalDirectory"); + createDirectory("qtbug15421_hiddenDirs_hiddenFiles/.hiddenDirectory/.hiddenDirectory"); } tst_QDirIterator::~tst_QDirIterator() @@ -578,6 +593,46 @@ void tst_QDirIterator::uncPaths() } #endif +void tst_QDirIterator::qtbug15421_hiddenDirs_hiddenFiles() +{ + // In Unix it is easy to create hidden files, but in Windows it requires + // a special call since hidden files need to be "marked" while in Unix + // anything starting by a '.' is a hidden file. + // For that reason this test is not run in Windows. +#if defined Q_OS_WIN || Q_OS_WINCE + QSKIP("To create hidden files a special call is required in Windows.", SkipAll); +#else + // Only files + { + int matches = 0; + int failures = 0; + QDirIterator di("qtbug15421_hiddenDirs_hiddenFiles", QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); + while (di.hasNext()) { + ++matches; + QString filename = di.next(); + if (QFileInfo(filename).isDir()) + ++failures; // search was only supposed to find files + } + QCOMPARE(matches, 6); + QCOMPARE(failures, 0); + } + // Only directories + { + int matches = 0; + int failures = 0; + QDirIterator di("qtbug15421_hiddenDirs_hiddenFiles", QDir::Dirs | QDir::Hidden | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); + while (di.hasNext()) { + ++matches; + QString filename = di.next(); + if (!QFileInfo(filename).isDir()) + ++failures; // search was only supposed to find files + } + QCOMPARE(matches, 6); + QCOMPARE(failures, 0); + } +#endif // Q_OS_WIN || Q_OS_WINCE +} + QTEST_MAIN(tst_QDirIterator) #include "tst_qdiriterator.moc" diff --git a/tests/auto/qftp/tst_qftp.cpp b/tests/auto/qftp/tst_qftp.cpp index 1b4b503..64d49d8 100644 --- a/tests/auto/qftp/tst_qftp.cpp +++ b/tests/auto/qftp/tst_qftp.cpp @@ -262,6 +262,10 @@ void tst_QFtp::init() void tst_QFtp::cleanup() { + if (ftp) { + delete ftp; + ftp = 0; + } QFETCH_GLOBAL(bool, setProxy); if (setProxy) { QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy); @@ -289,6 +293,7 @@ void tst_QFtp::connectToHost() QTestEventLoop::instance().enterLoop( 61 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -337,6 +342,7 @@ void tst_QFtp::connectToUnresponsiveHost() QVERIFY( it.value().success == 0 ); delete ftp; + ftp = 0; } void tst_QFtp::login_data() @@ -369,6 +375,7 @@ void tst_QFtp::login() QTestEventLoop::instance().enterLoop( 30 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -415,6 +422,7 @@ void tst_QFtp::close() QTestEventLoop::instance().enterLoop( 30 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -482,6 +490,7 @@ void tst_QFtp::list() QTestEventLoop::instance().enterLoop( 30 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -542,6 +551,7 @@ void tst_QFtp::cd() QTestEventLoop::instance().enterLoop( 30 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) { QFAIL( "Network operation timed out" ); } @@ -617,6 +627,7 @@ void tst_QFtp::get() QTestEventLoop::instance().enterLoop( 50 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -743,6 +754,7 @@ void tst_QFtp::put() break; } delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -775,6 +787,7 @@ void tst_QFtp::put() break; } delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -792,6 +805,7 @@ void tst_QFtp::put() QTestEventLoop::instance().enterLoop( timestep ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -860,6 +874,7 @@ void tst_QFtp::mkdir() QTestEventLoop::instance().enterLoop( 30 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -884,6 +899,7 @@ void tst_QFtp::mkdir() QTestEventLoop::instance().enterLoop( 30 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -903,6 +919,7 @@ void tst_QFtp::mkdir() QTestEventLoop::instance().enterLoop( 30 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -942,6 +959,7 @@ void tst_QFtp::mkdir2() QVERIFY(commandFinishedSpy.at(3).at(1).toBool()); delete ftp; + ftp = 0; } void tst_QFtp::mkdir2Slot(int id, bool) @@ -1019,6 +1037,7 @@ void tst_QFtp::renameInit( const QString &host, const QString &user, const QStri QTestEventLoop::instance().enterLoop( 50 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -1043,6 +1062,7 @@ void tst_QFtp::renameCleanup( const QString &host, const QString &user, const QS QTestEventLoop::instance().enterLoop( 30 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -1087,6 +1107,7 @@ void tst_QFtp::rename() QTestEventLoop::instance().enterLoop( 30 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -1273,6 +1294,7 @@ void tst_QFtp::commandSequence() QTestEventLoop::instance().enterLoop( 30 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -1330,6 +1352,7 @@ void tst_QFtp::abort() break; } delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -1367,6 +1390,7 @@ void tst_QFtp::abort() QTestEventLoop::instance().enterLoop( 30 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -1425,6 +1449,7 @@ void tst_QFtp::bytesAvailable() ftp->readAll(); QVERIFY( ftp->bytesAvailable() == 0 ); delete ftp; + ftp = 0; } void tst_QFtp::activeMode() @@ -1497,6 +1522,7 @@ void tst_QFtp::proxy() QTestEventLoop::instance().enterLoop( 50 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) { QFAIL( "Network operation timed out" ); } @@ -1531,6 +1557,8 @@ void tst_QFtp::binaryAscii() addCommand(QFtp::Close, ftp->close()); QTestEventLoop::instance().enterLoop( 30 ); + delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -1551,6 +1579,8 @@ void tst_QFtp::binaryAscii() addCommand(QFtp::Close, ftp->close()); QTestEventLoop::instance().enterLoop( 30 ); + delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -1573,6 +1603,7 @@ void tst_QFtp::binaryAscii() QTestEventLoop::instance().enterLoop( 30 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); @@ -1920,6 +1951,7 @@ bool tst_QFtp::fileExists( const QString &host, quint16 port, const QString &use inFileDirExistsFunction = TRUE; QTestEventLoop::instance().enterLoop( 30 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) { // ### make this test work qWarning("tst_QFtp::fileExists: Network operation timed out"); @@ -1970,6 +2002,7 @@ bool tst_QFtp::dirExists( const QString &host, quint16 port, const QString &user inFileDirExistsFunction = TRUE; QTestEventLoop::instance().enterLoop( 30 ); delete ftp; + ftp = 0; if ( QTestEventLoop::instance().timeout() ) { // ### make this test work // QFAIL( "Network operation timed out" ); @@ -1996,8 +2029,11 @@ void tst_QFtp::doneSignal() ftp.close(); done_success = 0; - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); + connect(&ftp, SIGNAL(done(bool)), &(QTestEventLoop::instance()), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(61); + if (QTestEventLoop::instance().timeout()) + QFAIL("Network operation timed out"); + QTest::qWait(200); QCOMPARE(spy.count(), 1); diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 168f75e..73e5656 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -66,6 +66,7 @@ #include <QPushButton> #include <QLineEdit> #include <QGraphicsLinearLayout> +#include <float.h> #include "../../shared/util.h" @@ -449,6 +450,8 @@ private slots: void scroll(); void focusHandling_data(); void focusHandling(); + void touchEventPropagation_data(); + void touchEventPropagation(); void deviceCoordinateCache_simpleRotations(); // task specific tests below me @@ -10637,6 +10640,80 @@ void tst_QGraphicsItem::focusHandling() QCOMPARE(scene.focusItem(), focusableUnder); } +void tst_QGraphicsItem::touchEventPropagation_data() +{ + QTest::addColumn<QGraphicsItem::GraphicsItemFlag>("flag"); + QTest::addColumn<int>("expectedCount"); + + QTest::newRow("ItemIsPanel") + << QGraphicsItem::ItemIsPanel << 0; + QTest::newRow("ItemStopsClickFocusPropagation") + << QGraphicsItem::ItemStopsClickFocusPropagation << 1; + QTest::newRow("ItemStopsFocusHandling") + << QGraphicsItem::ItemStopsFocusHandling << 1; +} + +void tst_QGraphicsItem::touchEventPropagation() +{ + QFETCH(QGraphicsItem::GraphicsItemFlag, flag); + QFETCH(int, expectedCount); + + class Testee : public QGraphicsRectItem + { + public: + int touchBeginEventCount; + + Testee() + : QGraphicsRectItem(0, 0, 100, 100) + , touchBeginEventCount(0) + { + setAcceptTouchEvents(true); + setFlag(QGraphicsItem::ItemIsFocusable, false); + } + + bool sceneEvent(QEvent *ev) + { + if (ev->type() == QEvent::TouchBegin) + ++touchBeginEventCount; + + return QGraphicsRectItem::sceneEvent(ev); + } + }; + + Testee *touchEventReceiver = new Testee; + QGraphicsItem *topMost = new QGraphicsRectItem(touchEventReceiver->boundingRect()); + + QGraphicsScene scene; + scene.addItem(topMost); + scene.addItem(touchEventReceiver); + + topMost->setAcceptTouchEvents(true); + topMost->setZValue(FLT_MAX); + topMost->setFlag(QGraphicsItem::ItemIsFocusable, false); + topMost->setFlag(flag, true); + + QGraphicsView view(&scene); + view.setSceneRect(touchEventReceiver->boundingRect()); + view.show(); + QTest::qWaitForWindowShown(&view); + + QCOMPARE(touchEventReceiver->touchBeginEventCount, 0); + + QTouchEvent::TouchPoint tp(0); + tp.setState(Qt::TouchPointPressed); + tp.setScenePos(view.sceneRect().center()); + tp.setLastScenePos(view.sceneRect().center()); + + QList<QTouchEvent::TouchPoint> touchPoints; + touchPoints << tp; + + sendMousePress(&scene, tp.scenePos()); + QTouchEvent touchBegin(QEvent::TouchBegin, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointPressed, touchPoints); + + qApp->sendEvent(&scene, &touchBegin); + QCOMPARE(touchEventReceiver->touchBeginEventCount, expectedCount); +} + void tst_QGraphicsItem::deviceCoordinateCache_simpleRotations() { // Make sure we don't invalidate the cache when applying simple @@ -11176,6 +11253,6 @@ void tst_QGraphicsItem::QTBUG_16374_crashInDestructor() view.show(); QTest::qWaitForWindowShown(&view); } - + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp index 9434a0b..903d7e7 100644 --- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp +++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp @@ -225,6 +225,10 @@ void tst_QGraphicsTransform::rotation() rotation.setAngle(90); QCOMPARE(transform2D(rotation).map(QPointF(10, 10)), QPointF(10, 10)); QCOMPARE(transform2D(rotation).map(QPointF(20, 10)), QPointF(10, 20)); + + rotation.setOrigin(QVector3D(0, 0, 0)); + rotation.setAngle(qQNaN()); + QCOMPARE(transform2D(rotation).map(QPointF(20, 10)), QPointF(20, 10)); } Q_DECLARE_METATYPE(Qt::Axis); diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index a6d4427..77a5574 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -391,6 +391,8 @@ void tst_QLocalSocket::listenAndConnect() QVERIFY(socket->fullServerName().contains(name)); sockets.append(socket); if (canListen) { + QVERIFY(socket->waitForConnected()); + QVERIFY(socket->isValid()); QCOMPARE(socket->errorString(), QString("Unknown error")); QCOMPARE(socket->error(), QLocalSocket::UnknownSocketError); QCOMPARE(socket->state(), QLocalSocket::ConnectedState); diff --git a/tests/auto/qmutex/tst_qmutex.cpp b/tests/auto/qmutex/tst_qmutex.cpp index ea983cb..a8c4b37 100644 --- a/tests/auto/qmutex/tst_qmutex.cpp +++ b/tests/auto/qmutex/tst_qmutex.cpp @@ -129,27 +129,57 @@ void tst_QMutex::tryLock() testsTurn.release(); threadsTurn.acquire(); + QVERIFY(!normalMutex.tryLock(0)); + testsTurn.release(); + + threadsTurn.acquire(); + timer.start(); + QVERIFY(normalMutex.tryLock(0)); + QVERIFY(timer.elapsed() < 1000); + QVERIFY(lockCount.testAndSetRelaxed(0, 1)); + QVERIFY(!normalMutex.tryLock(0)); + QVERIFY(lockCount.testAndSetRelaxed(1, 0)); + normalMutex.unlock(); + testsTurn.release(); + + threadsTurn.acquire(); } }; Thread thread; thread.start(); + // thread can't acquire lock + testsTurn.acquire(); + normalMutex.lock(); + QVERIFY(lockCount.testAndSetRelaxed(0, 1)); + threadsTurn.release(); + + // thread can acquire lock + testsTurn.acquire(); + QVERIFY(lockCount.testAndSetRelaxed(1, 0)); + normalMutex.unlock(); + threadsTurn.release(); + + // thread can't acquire lock, timeout = 1000 testsTurn.acquire(); normalMutex.lock(); QVERIFY(lockCount.testAndSetRelaxed(0, 1)); threadsTurn.release(); + // thread can acquire lock, timeout = 1000 testsTurn.acquire(); QVERIFY(lockCount.testAndSetRelaxed(1, 0)); normalMutex.unlock(); threadsTurn.release(); + // thread can't acquire lock, timeout = 0 testsTurn.acquire(); normalMutex.lock(); QVERIFY(lockCount.testAndSetRelaxed(0, 1)); threadsTurn.release(); + // thread can acquire lock, timeout = 0 testsTurn.acquire(); QVERIFY(lockCount.testAndSetRelaxed(1, 0)); normalMutex.unlock(); @@ -190,6 +220,7 @@ void tst_QMutex::tryLock() timer.start(); QVERIFY(!recursiveMutex.tryLock(1000)); QVERIFY(timer.elapsed() >= 1000); + QVERIFY(!recursiveMutex.tryLock(0)); testsTurn.release(); threadsTurn.acquire(); @@ -206,12 +237,47 @@ void tst_QMutex::tryLock() testsTurn.release(); threadsTurn.acquire(); + QVERIFY(!recursiveMutex.tryLock(0)); + QVERIFY(!recursiveMutex.tryLock(0)); + testsTurn.release(); + + threadsTurn.acquire(); + timer.start(); + QVERIFY(recursiveMutex.tryLock(0)); + QVERIFY(timer.elapsed() < 1000); + QVERIFY(lockCount.testAndSetRelaxed(0, 1)); + QVERIFY(recursiveMutex.tryLock(0)); + QVERIFY(lockCount.testAndSetRelaxed(1, 2)); + QVERIFY(lockCount.testAndSetRelaxed(2, 1)); + recursiveMutex.unlock(); + QVERIFY(lockCount.testAndSetRelaxed(1, 0)); + recursiveMutex.unlock(); + testsTurn.release(); + + threadsTurn.acquire(); } }; Thread thread; thread.start(); + // thread can't acquire lock + testsTurn.acquire(); + recursiveMutex.lock(); + QVERIFY(lockCount.testAndSetRelaxed(0, 1)); + recursiveMutex.lock(); + QVERIFY(lockCount.testAndSetRelaxed(1, 2)); + threadsTurn.release(); + + // thread can acquire lock + testsTurn.acquire(); + QVERIFY(lockCount.testAndSetRelaxed(2, 1)); + recursiveMutex.unlock(); + QVERIFY(lockCount.testAndSetRelaxed(1, 0)); + recursiveMutex.unlock(); + threadsTurn.release(); + + // thread can't acquire lock, timeout = 1000 testsTurn.acquire(); recursiveMutex.lock(); QVERIFY(lockCount.testAndSetRelaxed(0, 1)); @@ -219,6 +285,7 @@ void tst_QMutex::tryLock() QVERIFY(lockCount.testAndSetRelaxed(1, 2)); threadsTurn.release(); + // thread can acquire lock, timeout = 1000 testsTurn.acquire(); QVERIFY(lockCount.testAndSetRelaxed(2, 1)); recursiveMutex.unlock(); @@ -226,6 +293,7 @@ void tst_QMutex::tryLock() recursiveMutex.unlock(); threadsTurn.release(); + // thread can't acquire lock, timeout = 0 testsTurn.acquire(); recursiveMutex.lock(); QVERIFY(lockCount.testAndSetRelaxed(0, 1)); @@ -233,6 +301,7 @@ void tst_QMutex::tryLock() QVERIFY(lockCount.testAndSetRelaxed(1, 2)); threadsTurn.release(); + // thread can acquire lock, timeout = 0 testsTurn.acquire(); QVERIFY(lockCount.testAndSetRelaxed(2, 1)); recursiveMutex.unlock(); diff --git a/tests/auto/qpainterpath/tst_qpainterpath.cpp b/tests/auto/qpainterpath/tst_qpainterpath.cpp index 86adabb..c2e64e0 100644 --- a/tests/auto/qpainterpath/tst_qpainterpath.cpp +++ b/tests/auto/qpainterpath/tst_qpainterpath.cpp @@ -426,6 +426,10 @@ void tst_QPainterPath::intersects_QRectF_data() QTest::newRow("horizontal line") << linePath(0, 0, 10, 0) << QRectF(1, -1, 2, 2) << true; QTest::newRow("vertical line") << linePath(0, 0, 0, 10) << QRectF(-1, 1, 2, 2) << true; + + path = QPainterPath(); + path.addEllipse(QRectF(-5000.0, -5000.0, 1500000.0, 1500000.0)); + QTest::newRow("huge ellipse, qreal=float crash") << path << QRectF(1100000.35, 1098000.2, 1500000.0, 1500000.0) << true; } void tst_QPainterPath::intersects_QRectF() diff --git a/tests/auto/qpointer/tst_qpointer.cpp b/tests/auto/qpointer/tst_qpointer.cpp index 0485a17..67579fd 100644 --- a/tests/auto/qpointer/tst_qpointer.cpp +++ b/tests/auto/qpointer/tst_qpointer.cpp @@ -39,11 +39,8 @@ ** ****************************************************************************/ - #include <QtTest/QtTest> -#include <QApplication> -#include <QDebug> #include <QPointer> #include <QWidget> @@ -51,17 +48,9 @@ class tst_QPointer : public QObject { Q_OBJECT public: - tst_QPointer(); - ~tst_QPointer(); - inline tst_QPointer *me() const { return const_cast<tst_QPointer *>(this); } -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); private slots: void constructors(); void destructor(); @@ -71,29 +60,9 @@ private slots: void dereference_operators(); void disconnect(); void castDuringDestruction(); - void data() const; - void dataSignature() const; void threadSafety(); }; -tst_QPointer::tst_QPointer() -{ } - -tst_QPointer::~tst_QPointer() -{ } - -void tst_QPointer::initTestCase() -{ } - -void tst_QPointer::cleanupTestCase() -{ } - -void tst_QPointer::init() -{ } - -void tst_QPointer::cleanup() -{ } - void tst_QPointer::constructors() { QPointer<QObject> p1; @@ -106,11 +75,20 @@ void tst_QPointer::constructors() void tst_QPointer::destructor() { + // Make two QPointer's to the same object QObject *object = new QObject; - QPointer<QObject> p = object; - QCOMPARE(p, QPointer<QObject>(object)); + QPointer<QObject> p1 = object; + QPointer<QObject> p2 = object; + // Check that they point to the correct object + QCOMPARE(p1, QPointer<QObject>(object)); + QCOMPARE(p2, QPointer<QObject>(object)); + QCOMPARE(p1, p2); + // Destroy the guarded object delete object; - QCOMPARE(p, QPointer<QObject>(0)); + // Check that both pointers were zeroed + QCOMPARE(p1, QPointer<QObject>(0)); + QCOMPARE(p2, QPointer<QObject>(0)); + QCOMPARE(p1, p2); } void tst_QPointer::assignment_operators() @@ -118,19 +96,21 @@ void tst_QPointer::assignment_operators() QPointer<QObject> p1; QPointer<QObject> p2; + // Test assignment with a QObject-derived object pointer p1 = this; p2 = p1; - QCOMPARE(p1, QPointer<QObject>(this)); QCOMPARE(p2, QPointer<QObject>(this)); QCOMPARE(p1, QPointer<QObject>(p2)); + // Test assignment with a null pointer p1 = 0; p2 = p1; QCOMPARE(p1, QPointer<QObject>(0)); QCOMPARE(p2, QPointer<QObject>(0)); QCOMPARE(p1, QPointer<QObject>(p2)); + // Test assignment with a real QObject pointer QObject *object = new QObject; p1 = object; @@ -139,10 +119,15 @@ void tst_QPointer::assignment_operators() QCOMPARE(p2, QPointer<QObject>(object)); QCOMPARE(p1, QPointer<QObject>(p2)); - delete object; - QCOMPARE(p1, QPointer<QObject>(0)); - QCOMPARE(p2, QPointer<QObject>(0)); + // Test assignment with the same pointer that's already guarded + p1 = object; + p2 = p1; + QCOMPARE(p1, QPointer<QObject>(object)); + QCOMPARE(p2, QPointer<QObject>(object)); QCOMPARE(p1, QPointer<QObject>(p2)); + + // Cleanup + delete object; } void tst_QPointer::equality_operators() @@ -196,19 +181,28 @@ void tst_QPointer::isNull() void tst_QPointer::dereference_operators() { QPointer<tst_QPointer> p1 = this; + QPointer<tst_QPointer> p2; + // operator->() -- only makes sense if not null QObject *object = p1->me(); - QVERIFY(object == this); + QCOMPARE(object, this); + // operator*() -- only makes sense if not null QObject &ref = *p1; - QVERIFY(&ref == this); + QCOMPARE(&ref, this); + + // operator T*() + QCOMPARE(static_cast<QObject *>(p1), this); + QCOMPARE(static_cast<QObject *>(p2), static_cast<QObject *>(0)); - object = static_cast<QObject *>(p1); - QVERIFY(object == this); + // data() + QCOMPARE(p1.data(), this); + QCOMPARE(p2.data(), static_cast<QObject *>(0)); } void tst_QPointer::disconnect() { + // Verify that pointer remains guarded when all signals are disconencted. QPointer<QObject> p1 = new QObject; QVERIFY(!p1.isNull()); p1->disconnect(); @@ -314,38 +308,6 @@ void tst_QPointer::castDuringDestruction() } } -void tst_QPointer::data() const -{ - /* Check value of a default constructed object. */ - { - QPointer<QObject> p; - QCOMPARE(p.data(), static_cast<QObject *>(0)); - } - - /* Check value of a default constructed object. */ - { - QObject *const object = new QObject(); - QPointer<QObject> p(object); - QCOMPARE(p.data(), object); - } -} - -void tst_QPointer::dataSignature() const -{ - /* data() should be const. */ - { - const QPointer<QObject> p; - p.data(); - } - - /* The return type should be T. */ - { - const QPointer<QWidget> p; - /* If the types differs, the QCOMPARE will fail to instansiate. */ - QCOMPARE(p.data(), static_cast<QWidget *>(0)); - } -} - class TestRunnable : public QObject, public QRunnable { void run() { QPointer<QObject> obj1 = new QObject; diff --git a/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp b/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp index ea06295..1c26343 100644 --- a/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp +++ b/tests/auto/qprocessenvironment/tst_qprocessenvironment.cpp @@ -56,6 +56,8 @@ private slots: void insert(); void emptyNull(); void toStringList(); + void keys(); + void insertEnv(); void caseSensitivity(); void systemEnvironment(); @@ -154,6 +156,58 @@ void tst_QProcessEnvironment::toStringList() QVERIFY(result.contains("HELLO=World")); } +void tst_QProcessEnvironment::keys() +{ + QProcessEnvironment e; + QVERIFY(e.isEmpty()); + QVERIFY(e.keys().isEmpty()); + + e.insert("FOO", "bar"); + QStringList result = e.keys(); + QCOMPARE(result.length(), 1); + QCOMPARE(result.at(0), QString("FOO")); + + e.clear(); + e.insert("BAZ", ""); + result = e.keys(); + QCOMPARE(result.at(0), QString("BAZ")); + + e.insert("FOO", "bar"); + e.insert("A", "bc"); + e.insert("HELLO", "World"); + result = e.keys(); + QCOMPARE(result.length(), 4); + + // order is not specified, so use contains() + QVERIFY(result.contains("FOO")); + QVERIFY(result.contains("BAZ")); + QVERIFY(result.contains("A")); + QVERIFY(result.contains("HELLO")); +} + +void tst_QProcessEnvironment::insertEnv() +{ + QProcessEnvironment e; + e.insert("FOO", "bar"); + e.insert("A", "bc"); + e.insert("Hello", "World"); + + QProcessEnvironment e2; + e2.insert("FOO2", "bar2"); + e2.insert("A2", "bc2"); + e2.insert("Hello", "Another World"); + + e.insert(e2); + QStringList keys = e.keys(); + QCOMPARE(keys.length(), 5); + + QCOMPARE(e.value("FOO"), QString("bar")); + QCOMPARE(e.value("A"), QString("bc")); + QCOMPARE(e.value("Hello"), QString("Another World")); + QCOMPARE(e.value("FOO2"), QString("bar2")); + QCOMPARE(e.value("A2"), QString("bc2")); +} + void tst_QProcessEnvironment::caseSensitivity() { QProcessEnvironment e; diff --git a/tests/auto/qsemaphore/tst_qsemaphore.cpp b/tests/auto/qsemaphore/tst_qsemaphore.cpp index ba2175a..9fc6de1 100644 --- a/tests/auto/qsemaphore/tst_qsemaphore.cpp +++ b/tests/auto/qsemaphore/tst_qsemaphore.cpp @@ -244,6 +244,8 @@ void tst_QSemaphore::tryAcquireWithTimeout() QSemaphore semaphore; QTime time; +#define QVERIFYGE(a,b) {int e = a; if (a<b) qDebug() << #a << "=" << e << " !>= " << #b << "=" << b; QVERIFY(e>=b);} +#define QVERIFYLE(a,b) {int e = a; if (b<a) qDebug() << #a << "=" << e << " !<= " << #b << "=" << b; QVERIFY(e<=b);} QCOMPARE(semaphore.available(), 0); @@ -251,69 +253,69 @@ void tst_QSemaphore::tryAcquireWithTimeout() QCOMPARE(semaphore.available(), 1); time.start(); QVERIFY(!semaphore.tryAcquire(2, timeout)); - QVERIFY(time.elapsed() >= timeout); + QVERIFYGE(time.elapsed(), timeout); QCOMPARE(semaphore.available(), 1); semaphore.release(); QCOMPARE(semaphore.available(), 2); time.start(); QVERIFY(!semaphore.tryAcquire(3, timeout)); - QVERIFY(time.elapsed() >= timeout); + QVERIFYGE(time.elapsed(), timeout); QCOMPARE(semaphore.available(), 2); semaphore.release(10); QCOMPARE(semaphore.available(), 12); time.start(); QVERIFY(!semaphore.tryAcquire(100, timeout)); - QVERIFY(time.elapsed() >= timeout); + QVERIFYGE(time.elapsed(), timeout); QCOMPARE(semaphore.available(), 12); semaphore.release(10); QCOMPARE(semaphore.available(), 22); time.start(); QVERIFY(!semaphore.tryAcquire(100, timeout)); - QVERIFY(time.elapsed() >= timeout); + QVERIFYGE(time.elapsed(), timeout); QCOMPARE(semaphore.available(), 22); time.start(); QVERIFY(semaphore.tryAcquire(1, timeout)); - QVERIFY(time.elapsed() <= timeout); + QVERIFYLE(time.elapsed(), timeout); QCOMPARE(semaphore.available(), 21); time.start(); QVERIFY(semaphore.tryAcquire(1, timeout)); - QVERIFY(time.elapsed() <= timeout); + QVERIFYLE(time.elapsed(), timeout); QCOMPARE(semaphore.available(), 20); time.start(); QVERIFY(semaphore.tryAcquire(10, timeout)); - QVERIFY(time.elapsed() <= timeout); + QVERIFYLE(time.elapsed(), timeout); QCOMPARE(semaphore.available(), 10); time.start(); QVERIFY(semaphore.tryAcquire(10, timeout)); - QVERIFY(time.elapsed() <= timeout); + QVERIFYLE(time.elapsed(), timeout); QCOMPARE(semaphore.available(), 0); // should not be able to acquire more time.start(); QVERIFY(!semaphore.tryAcquire(1, timeout)); - QVERIFY(time.elapsed() >= timeout); + QVERIFYGE(time.elapsed(), timeout); QCOMPARE(semaphore.available(), 0); time.start(); QVERIFY(!semaphore.tryAcquire(1, timeout)); - QVERIFY(time.elapsed() >= timeout); + QVERIFYGE(time.elapsed(), timeout); QCOMPARE(semaphore.available(), 0); time.start(); QVERIFY(!semaphore.tryAcquire(10, timeout)); - QVERIFY(time.elapsed() >= timeout); + QVERIFYGE(time.elapsed(), timeout); QCOMPARE(semaphore.available(), 0); time.start(); QVERIFY(!semaphore.tryAcquire(10, timeout)); - QVERIFY(time.elapsed() >= timeout); + QVERIFYGE(time.elapsed(), timeout); QCOMPARE(semaphore.available(), 0); } diff --git a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp index 910d437..bd19afb 100644 --- a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp +++ b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp @@ -179,8 +179,8 @@ void tst_QSoftKeyManager::handleCommand() // QTest::keyPress(&w, Qt::Key_Context1); // QTest::keyPress(&w, Qt::Key_Context2); - simulateSymbianCommand(6000); - simulateSymbianCommand(6001); + simulateSymbianCommand(s60CommandStart); //0 = LSK position + simulateSymbianCommand(s60CommandStart + 2); //2 = RSK position QApplication::processEvents(); @@ -205,28 +205,32 @@ void tst_QSoftKeyManager::checkSoftkeyEnableStates() w.show(); QApplication::processEvents(); - QSignalSpy spy0(w.actions()[0], SIGNAL(triggered())); //restore defaults action - QSignalSpy spy1(w.actions()[1], SIGNAL(triggered())); //disabled help action + //According to StandardButton enum in QDialogButtonBox the Help action + //is inserted before RestoreDefaults and thus help action is in index 0 + QSignalSpy spy0(w.actions()[0], SIGNAL(triggered())); //disabled help action + QSignalSpy spy1(w.actions()[1], SIGNAL(triggered())); //restore defaults action //Verify that enabled button gets all the action trigger signals and //disabled button gets none. for (int i = 0; i < 10; i++) { - //simulate "Restore Defaults" softkey press - simulateSymbianCommand(s60CommandStart); //simulate "help" softkey press - simulateSymbianCommand(s60CommandStart + 1); + simulateSymbianCommand(s60CommandStart); + //simulate "Restore Defaults" softkey press + simulateSymbianCommand(s60CommandStart + 2); } QApplication::processEvents(); - QCOMPARE(spy0.count(), 10); - QCOMPARE(spy1.count(), 0); + //Restore defaults button is enabled and its signals are recorded to spy1 + QCOMPARE(spy0.count(), 0); + QCOMPARE(spy1.count(), 10); + spy0.clear(); spy1.clear(); for (int i = 0; i < 10; i++) { - //simulate "Restore Defaults" softkey press - simulateSymbianCommand(s60CommandStart); //simulate "help" softkey press - simulateSymbianCommand(s60CommandStart + 1); + simulateSymbianCommand(s60CommandStart); + //simulate "Restore Defaults" softkey press + simulateSymbianCommand(s60CommandStart + 2); //switch enabled button to disabled and vice versa pBHelp->setEnabled(!pBHelp->isEnabled()); pBDefaults->setEnabled(!pBDefaults->isEnabled()); @@ -261,7 +265,7 @@ void tst_QSoftKeyManager::noMergingOverWindowBoundary() //Verify that both base softkeys emit triggered signals simulateSymbianCommand(s60CommandStart); - simulateSymbianCommand(s60CommandStart + 1); + simulateSymbianCommand(s60CommandStart + 2); QCOMPARE(baseLeftSpy.count(), 1); QCOMPARE(baseRightSpy.count(), 1); @@ -275,7 +279,7 @@ void tst_QSoftKeyManager::noMergingOverWindowBoundary() QApplication::processEvents(); simulateSymbianCommand(s60CommandStart); - simulateSymbianCommand(s60CommandStart + 1); + simulateSymbianCommand(s60CommandStart + 2); QCOMPARE(baseLeftSpy.count(), 0); QCOMPARE(baseRightSpy.count(), 0); @@ -291,7 +295,7 @@ void tst_QSoftKeyManager::noMergingOverWindowBoundary() QApplication::processEvents(); simulateSymbianCommand(s60CommandStart); - simulateSymbianCommand(s60CommandStart + 1); + simulateSymbianCommand(s60CommandStart + 2); QCOMPARE(baseLeftSpy.count(), 0); QCOMPARE(baseRightSpy.count(), 0); diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 288b29c..be2087d 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -928,13 +928,12 @@ void tst_QSqlQuery::record() QSqlQuery q( db ); QVERIFY( q.record().isEmpty() ); QVERIFY_SQL( q, exec( "select id, t_varchar, t_char from " + qtest + " order by id" ) ); - QSqlRecord rec = q.record(); QCOMPARE( q.record().fieldName( 0 ).toLower(), QString( "id" ) ); QCOMPARE( q.record().fieldName( 1 ).toLower(), QString( "t_varchar" ) ); QCOMPARE( q.record().fieldName( 2 ).toLower(), QString( "t_char" ) ); - QVERIFY( !q.record().value( 0 ).isValid() ); - QVERIFY( !q.record().value( 1 ).isValid() ); - QVERIFY( !q.record().value( 2 ).isValid() ); + QCOMPARE(q.record().value(0), QVariant(q.record().field(0).type())); + QCOMPARE(q.record().value(1), QVariant(q.record().field(1).type())); + QCOMPARE(q.record().value(2), QVariant(q.record().field(2).type())); QVERIFY( q.next() ); QVERIFY( q.next() ); diff --git a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp index e876764..9507e54 100644 --- a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp +++ b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp @@ -428,9 +428,9 @@ void tst_QSqlQueryModel::record() QCOMPARE(rec.fieldName(0), isToUpper ? QString("ID") : QString("id")); QCOMPARE(rec.fieldName(1), isToUpper ? QString("NAME") : QString("name")); QCOMPARE(rec.fieldName(2), isToUpper ? QString("TITLE") : QString("title")); - QCOMPARE(rec.value(0), QVariant()); - QCOMPARE(rec.value(1), QVariant()); - QCOMPARE(rec.value(2), QVariant()); + QCOMPARE(rec.value(0), QVariant(rec.field(0).type())); + QCOMPARE(rec.value(1), QVariant(rec.field(1).type())); + QCOMPARE(rec.value(2), QVariant(rec.field(2).type())); rec = model.record(0); QCOMPARE(rec.fieldName(0), isToUpper ? QString("ID") : QString("id")); diff --git a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp index bf68375..b91d025 100644 --- a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp @@ -569,9 +569,9 @@ void tst_QSqlTableModel::insertMultiRecords() QVERIFY(model.insertRow(2)); - QCOMPARE(model.data(model.index(2, 0)), QVariant()); - QCOMPARE(model.data(model.index(2, 1)), QVariant()); - QCOMPARE(model.data(model.index(2, 2)), QVariant()); + QCOMPARE(model.data(model.index(2, 0)), QVariant(model.record().field(0).type())); + QCOMPARE(model.data(model.index(2, 1)), QVariant(model.record().field(1).type())); + QCOMPARE(model.data(model.index(2, 2)), QVariant(model.record().field(2).type())); QVERIFY(model.insertRow(3)); QVERIFY(model.insertRow(0)); diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted1.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted1.pem new file mode 100644 index 0000000..3945aea --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted1.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDzCCAnigAwIBAgIQBH7L6fylX3vQnq424QyuHjANBgkqhkiG9w0BAQUFADBf +MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 +ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRgwFgYDVQQDEw9tYWlsLmdvb2dsZS5jb20w +HhcNMTEwMzI0MTMwNjI1WhcNMTEwNDIzMTMwNjI1WjBfMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRgwFgYDVQQDEw9tYWlsLmdvb2dsZS5jb20wgZ8wDQYJKoZIhvcNAQEB +BQADgY0AMIGJAoGBAOeAGV2FbGnT4rLjTvCNEEDjj0/iIUATa6RT8WKF2PVaOzbE +oceiODx6hTStvBnCgs+h/d3eVKgp+uAyBde5sW/HlOwHrNgKF3ZDvxegzIOEHaVI +ndNtBpFS3UyOEkO0NxfioBatNRYpeTRU/DVmazu3yvzgrV1V2mDsrNngVWxJAgMB +AAGjgcswgcgwHQYDVR0OBBYEFHcF1eqRpm7B78aY8ZjseN6zSYbvMIGYBgNVHSME +gZAwgY2AFHcF1eqRpm7B78aY8ZjseN6zSYbvoWOkYTBfMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRgwFgYDVQQDEw9tYWlsLmdvb2dsZS5jb22CEAR+y+n8pV970J6uNuEM +rh4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQBEb1iF+EbhAJli5Sj2 ++iEdJ5xMP8R6FtgqAYknqXD8+tyEyXxJXdN186qdAWuTD9N22AUqi61BPWxUkufW +xH8FYMEHdFCkitvYE0321+GT5pJz6ON/d5Co+wusumt7T5oSjzj8Ax9V+nmo3Nkb +dSANM4/Lnc6moijcpJZq+GC1ng== +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted2.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted2.pem new file mode 100644 index 0000000..4b8d059 --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted2.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDjCCAnegAwIBAgIRAPXIavNhYvE6ZPVPbclYfAYwDQYJKoZIhvcNAQEFBQAw +XjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu +dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEXMBUGA1UEAxMOd3d3Lmdvb2dsZS5jb20w +HhcNMTEwMzI0MTMwNzExWhcNMTEwNDIzMTMwNzExWjBeMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRcwFQYDVQQDEw53d3cuZ29vZ2xlLmNvbTCBnzANBgkqhkiG9w0BAQEF +AAOBjQAwgYkCgYEAy1fNDFl65Njfcd1EUJeaxvyiKln+JKlqUmk1x4mrE1BQoa0C +QZaiXAF21rDhivWejZWBiEQ4IWbg3b12ANY74G1KqAfLC4BNKS9UP94hy18vezRA +pFc+m/HAClwc8AdACpl8eZpQW8cMgdvnMBMZTrQkgV0JYykX+uDD9Tb+QNUCAwEA +AaOByzCByDAdBgNVHQ4EFgQUSelG6IVRj2ZQbp049zkQ0X/Po9wwgZgGA1UdIwSB +kDCBjYAUSelG6IVRj2ZQbp049zkQ0X/Po9yhYqRgMF4xCzAJBgNVBAYTAkFVMRMw +EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0 +eSBMdGQxFzAVBgNVBAMTDnd3dy5nb29nbGUuY29tghEA9chq82Fi8Tpk9U9tyVh8 +BjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBALQyDC/AMQMNj2fa6E8L +umILCklWJwG1K1p/1bUAgm0CB8zm94n1xrh/ZK4+HS+k2a9OQmvLRbFyJn8Wua8p +3UU0267UNkCanA1FKHuO3Mo18wLvjMLWjjCQ4g1C9IvJx6P+8EFDQFG+MJBV/w2k +gJXXVl3q1T1dvahIgfav9QBL +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted3.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted3.pem new file mode 100644 index 0000000..e47ece6 --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted3.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDETCCAnqgAwIBAgIRANdVj9r18RBbshMoK3B3KaMwDQYJKoZIhvcNAQEFBQAw +XzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu +dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4ueWFob28uY29t +MB4XDTExMDMyNDEzMDg0MloXDTExMDQyMzEzMDg0MlowXzELMAkGA1UEBhMCQVUx +EzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMg +UHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4ueWFob28uY29tMIGfMA0GCSqGSIb3DQEB +AQUAA4GNADCBiQKBgQCosFLKRvGtxjvdAjWdEAHYycFTa4VtdpXmCNhNHf2xbeLn +xzde10KjEe44pQxNI+UUD1rJkyuH6wUfloyefn0D2Mu+MvusmvOEzFosa4EDbK9s +BAAlsSiyJgrp/GgbEPq/XOl4XJRBIVP1WC6LllduNbskFCipDqS+HQwifXmmwQID +AQABo4HMMIHJMB0GA1UdDgQWBBSEgWnsoYtd5GEx/MGJvKxuIuROJzCBmQYDVR0j +BIGRMIGOgBSEgWnsoYtd5GEx/MGJvKxuIuROJ6FjpGEwXzELMAkGA1UEBhMCQVUx +EzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMg +UHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4ueWFob28uY29tghEA11WP2vXxEFuyEygr +cHcpozAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAKNpIrzTOxIykKZt +EE6HU2nW1lrWUkIMjwjL8ntw7QI4JLMDN1ADVIxWaGTeQ+U/eXFou6dDNAYVAijK +ONDXgOItxW2YvSw0wOZsZj6INX2x88/0yRH+19TqaL/r+Y1D1h/0zefkHgfXufnY +Ex7BHju/rGBTp6R1mr+Tlh1tewva +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted4.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted4.pem new file mode 100644 index 0000000..64c7d41 --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted4.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDzCCAnigAwIBAgIQOSpDTw4H3x+KowXeNODCKTANBgkqhkiG9w0BAQUFADBf +MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 +ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb20w +HhcNMTEwMzI0MTMwOTE1WhcNMTEwNDIzMTMwOTE1WjBfMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb20wgZ8wDQYJKoZIhvcNAQEB +BQADgY0AMIGJAoGBANO2gz9x2H92xz5OvZSEul9gHxqqd+kdjeoS2exyvjC9wzqb +gYXqNmAsbtNp4WmieEQFd0riCAEkIAn8JpHTCsMHN4rHhS+W+4D5a/drI2jfnZEF +orNYJG1PHSQV/rvh6d7wkVdT+0SYOjrFTAA2biGWaK3W9ztf2yX577w+uQtBAgMB +AAGjgcswgcgwHQYDVR0OBBYEFJjDp8Prs7oReRmskIeFixp0vDkGMIGYBgNVHSME +gZAwgY2AFJjDp8Prs7oReRmskIeFixp0vDkGoWOkYTBfMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb22CEDkqQ08OB98fiqMF3jTg +wikwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQAZyo0Q3leeM1+lxeCd +Wp0ZYHMSW11ANc6nuMWOmJC+nIQGlyGiP3IqeUvIfekwboV638bahVPwcl2HYWsS +/l01Bgyd25Zn6VTQBfMK01dILyxscjVwdHuojzYBN05sl+qkVoqQr5EroQQbgDc9 +6I88p6Kjajv3IusCwfK6wlqISw== +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted5.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted5.pem new file mode 100644 index 0000000..c7ddbf2 --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted5.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDzCCAnigAwIBAgIQPnXO1GtpMCEhiDCuhqgqcTANBgkqhkiG9w0BAQUFADBf +MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 +ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb20w +HhcNMTEwMzI0MTMwOTQ4WhcNMTEwNDIzMTMwOTQ4WjBfMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb20wgZ8wDQYJKoZIhvcNAQEB +BQADgY0AMIGJAoGBALkiHG9TgTw/00CMW8D23NBDAa3331AL5kTkAaXbAWg2R/1o +yKQfXq3hgHbyWGPccUT+tU6FmaBf3bIndLK7iGx81RGzGgXeoQ5mpgnJ50iCeW73 +G99VlVwutPia7d9qqui84YdcG9t+P2Fuxv+xRqAB6lKOaa4qTPIbH50PgwOvAgMB +AAGjgcswgcgwHQYDVR0OBBYEFBWJrs8bnZ5fikfaLbTxK0ssj69MMIGYBgNVHSME +gZAwgY2AFBWJrs8bnZ5fikfaLbTxK0ssj69MoWOkYTBfMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb22CED51ztRraTAhIYgwroao +KnEwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCIfqqs1a7RzdmV8U00 +v/xAsxscKvQvmu6BK+HwvY5iL2pSwXTYgRLJLoj5QGOd3mmgOFsyW3BPSCP1+fVE +M1ROhU2u8wHub+hGGds18Fx6F4yZjdh8pNUoOUR9A0Ym+VDJr2p50oUNTTy0RbH8 +9ns/gbemx84cjF9DD2G5stQhYg== +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted6.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted6.pem new file mode 100644 index 0000000..bc2be2a --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted6.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDETCCAnqgAwIBAgIRAOkCi5V45BXcGnEKK4gVREcwDQYJKoZIhvcNAQEFBQAw +XzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu +dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4uc2t5cGUuY29t +MB4XDTExMDMyNDEzMTAxNloXDTExMDQyMzEzMTAxNlowXzELMAkGA1UEBhMCQVUx +EzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMg +UHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4uc2t5cGUuY29tMIGfMA0GCSqGSIb3DQEB +AQUAA4GNADCBiQKBgQDFq06qqRl86pP7GRX3m7FMMSaSU6zlNGAo+WPoRfYAzB6x +5KpvlfxMCo3T/nWtInX3Bw9TBWCZSweQ2GEjggO0irjw5UX3MiToLxK+rwzWztm9 +H3LBxTWR0cOOa78kRFvNQ1onvNHbs8fJzXjG7b2IJDOIwG1HAT1LK80oPXZc1wID +AQABo4HMMIHJMB0GA1UdDgQWBBTiGNxw0ImW/wfW0mD3eA65PY5CAzCBmQYDVR0j +BIGRMIGOgBTiGNxw0ImW/wfW0mD3eA65PY5CA6FjpGEwXzELMAkGA1UEBhMCQVUx +EzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMg +UHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4uc2t5cGUuY29tghEA6QKLlXjkFdwacQor +iBVERzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAHdb1QY/oxuro/4x +GX9jbm930ysoeXkWZSKVtVxoxrPIferu8jVpb1SLRjGcMnmjJoNWNFpvnbZgoYei +f3wdSWun7ndyQBh61k8eM7UABDOUXUHOsHuHj7s1koMKtet4gykmMfd6VxBkwBvN +ZXOll4X+TKe8nrxbnGUByIwQaRM+ +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted7.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted7.pem new file mode 100644 index 0000000..19d4353 --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted7.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDGjCCAoOgAwIBAgIRAJI51TSPQNFpWnRUcOHyP0MwDQYJKoZIhvcNAQEFBQAw +YjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu +dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEbMBkGA1UEAxMSYWRkb25zLm1vemlsbGEu +b3JnMB4XDTExMDMyNDEzMTA0NFoXDTExMDQyMzEzMTA0NFowYjELMAkGA1UEBhMC +QVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdp +dHMgUHR5IEx0ZDEbMBkGA1UEAxMSYWRkb25zLm1vemlsbGEub3JnMIGfMA0GCSqG +SIb3DQEBAQUAA4GNADCBiQKBgQC1lsoAcZTwF8Pf0E9do5avLdobB/O7EhhrCMs2 +/EMO07aIlrLwl3UP/Fmu/cAkKuX8Mx+Eif9x+XT3ZqGKGYKiqPTJcNfeZvgwbn0j +wXDtEo4DuURrwtBU9okS+v4dF6F4RtHQKAGcsXoOjhR7ah71kve+PG2GG0sJ167V +klK1xwIDAQABo4HPMIHMMB0GA1UdDgQWBBRgGDJ4Qp0WFyLIzm4Nz5wgqDSSxjCB +nAYDVR0jBIGUMIGRgBRgGDJ4Qp0WFyLIzm4Nz5wgqDSSxqFmpGQwYjELMAkGA1UE +BhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdp +ZGdpdHMgUHR5IEx0ZDEbMBkGA1UEAxMSYWRkb25zLm1vemlsbGEub3JnghEAkjnV +NI9A0WladFRw4fI/QzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBACeE +DHMQ+LWEuoa/6z2EgrgM1k9rvBbUtCR+rjTuyzVW4OLXdpiVwZPOAiKphpq7q8Sb +TQ3zwsCoPLLJk5VolwcPfcD8Y2/tYK3NCYl+HzGxxnzPDFVaZM5Jh8RI861Hc00D +hVoQaptPK/V/lr0KEevqjhusAdFZbwlWA923zASa +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted8.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted8.pem new file mode 100644 index 0000000..aedf3f7 --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted8.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDjCCAnegAwIBAgIRALC3Ez7Qlvm1b66RyHS9OsAwDQYJKoZIhvcNAQEFBQAw +XjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu +dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEXMBUGA1UEAxMObG9naW4ubGl2ZS5jb20w +HhcNMTEwMzI0MTMxMTA2WhcNMTEwNDIzMTMxMTA2WjBeMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRcwFQYDVQQDEw5sb2dpbi5saXZlLmNvbTCBnzANBgkqhkiG9w0BAQEF +AAOBjQAwgYkCgYEA3OVNj9ijzMewvDeZYzgCWoKtyjclyIHxrQfHZpcexaKbxUap +1MtF6L0ayjtRWpiBYuPteUSy/Ja4Oh6zZz8K6z5rVgXhmy3xPIYuOoWaTKEOhb0Z +oHTBtGh8aWWai1XWw37HIm2FP8cmfgdH4lZwVvpTZIUxYidsyqyjB9IrhiMCAwEA +AaOByzCByDAdBgNVHQ4EFgQU4CcQcIvEhJC0tqHlNFMkv6MlDN4wgZgGA1UdIwSB +kDCBjYAU4CcQcIvEhJC0tqHlNFMkv6MlDN6hYqRgMF4xCzAJBgNVBAYTAkFVMRMw +EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0 +eSBMdGQxFzAVBgNVBAMTDmxvZ2luLmxpdmUuY29tghEAsLcTPtCW+bVvrpHIdL06 +wDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAMNzIStXDNSNQ8ayxrcj +4RrUMsHWUG/6XPrgfYqCP5TfPGAa5qBfNb9LfUbiS4b0flJVN1RlHVwwRo0yf9v4 +LGg0dSuPQAOWlLeUR1GminO1jHZw7E4dYfR7QEmiiOgaQU+CbxLsf5vCaKInN9Gu +jv/5xytVCbMoLoZ4EBVb0tka +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted9.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted9.pem new file mode 100644 index 0000000..d179b29 --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted9.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDjCCAnegAwIBAgIRANjzX063hystqwaS4xU4L7AwDQYJKoZIhvcNAQEFBQAw +XjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu +dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEXMBUGA1UEAxMOZ2xvYmFsIHRydXN0ZWUw +HhcNMTEwMzI0MTMxMTM3WhcNMTEwNDIzMTMxMTM3WjBeMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRcwFQYDVQQDEw5nbG9iYWwgdHJ1c3RlZTCBnzANBgkqhkiG9w0BAQEF +AAOBjQAwgYkCgYEArHCVym7AEZDBhDkrUSG3Q94a+caNcCk5fE6ltZHiZHv096xr +cixHYvSGvms780bkI+oot2xI/e9awwkV+7VjWNvr0HrajzBWeimwk+myjP+3ddMY +Kmr0eI6bmvmPHtOFJE5Ar8/62FwD0wlLogRIx56JtXcCpkiUQktJVPz2gtMCAwEA +AaOByzCByDAdBgNVHQ4EFgQUUJwC/qSGBmcB+DVrd43ovRLdLmQwgZgGA1UdIwSB +kDCBjYAUUJwC/qSGBmcB+DVrd43ovRLdLmShYqRgMF4xCzAJBgNVBAYTAkFVMRMw +EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0 +eSBMdGQxFzAVBgNVBAMTDmdsb2JhbCB0cnVzdGVlghEA2PNfTreHKy2rBpLjFTgv +sDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBACAYxI+r3+JNelL6SBB0 +Pda3LkbCm+schP64NBYDdGl2Kus2b2QZ83T7xENBFEhyNoXvc6pRI4/Oh6JDxmG1 +7WmqOVStS/4JeAu6ygiyI1ImRKq2/MvJx/kaKh6IiXanB5nW1U+fhDV6kMOEfpwV +i6FBibpHboPQoqzPPRe7qHSL +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index 1e3a8dd..57f2fa8 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -111,6 +111,8 @@ private slots: void nulInSan(); void largeSerialNumber(); void largeExpirationDate(); + void blacklistedCertificates(); + // ### add tests for certificate bundles (multiple certificates concatenated into a single // structure); both PEM and DER formatted #endif @@ -817,6 +819,15 @@ void tst_QSslCertificate::largeExpirationDate() // QTBUG-12489 QCOMPARE(cert.expiryDate().toUTC(), QDateTime(QDate(2051, 8, 29), QTime(9, 53, 41), Qt::UTC)); } +void tst_QSslCertificate::blacklistedCertificates() +{ + QList<QSslCertificate> blacklistedCerts = QSslCertificate::fromPath("more-certificates/blacklisted*.pem", QSsl::Pem, QRegExp::Wildcard); + QVERIFY2(blacklistedCerts.count() > 0, "Please run this test from the source directory"); + for (int a = 0; a < blacklistedCerts.count(); a++) { + QVERIFY(! blacklistedCerts.at(a).isValid()); + } +} + #endif // QT_NO_OPENSSL QTEST_MAIN(tst_QSslCertificate) diff --git a/tests/auto/qsslsocket/certs/fake-login.live.com.key b/tests/auto/qsslsocket/certs/fake-login.live.com.key new file mode 100644 index 0000000..692a7bd --- /dev/null +++ b/tests/auto/qsslsocket/certs/fake-login.live.com.key @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXQIBAAKBgQDOtxdvMa0VHUQYG5q7Tsi1Jj4qKEJppyZEkmuRXOi0fDbd1SwE +bwHrLGMvDO6OMrYBbq3WDNrtnIfF9CvzUOEch+gjr4hEVQqecU5fb45Wor7yNel3 +/C/gxfbzuXHrsj/gUjNghL2i10+c2NW+hUo/sWO6OusaBT6d6s7ee+YBcQIDAQAB +AoGAb8cVhu0HuLkgjyCuJMbPRRUu3ED02Iin6sB6JhplQuNAD+grayJTmUVhRJnr +jTziqhedLHe7Em1oBaSo92MutfMpXvWiccSlbNygI61VgmrJpVB+qIN5H9cQc9ql +Zymc+nIPa1+i5rsrOzlpUytTh7AsbZ27QG4tQXR/kQejEiECQQD6BgTxBeT8D7x9 +DuukoBaSCkLwx7U7P1NXx15EI3lA1nO51t6UHfvk/jGPp8Sl4wv4alJ7AQxr5uQ/ +vC3kzA/1AkEA06gNu10se8pe3n8qL2RRt+FmVjHkQdD9Mm2Dx9oWCs2A4wOSOrlo +6/nKYF1CaQNYn9HgsNbHVEUpnICVO18qDQJBALEw/uOJ1+TDikPfBSWgxx4s45Ad +GNWqZXh6NNZ5hX9r/IwiOZAjR9fcRmeW8IjYRi2BvH6sGY+HDRAWXzgdXtkCQCma +dOiJTf8fLjqp4E7kdzOfuI/kyqstOze4Uxjrgz2oW1dEEnA8laUcumzqp+0gXUE8 +7d+UuCWWWrGKjMrYz9kCQQDh5E5+b6Djn082Jo6gvyuXWC5eXju6IdmihlJ2SMzD +s2y3IDjOUtTeQQRDymLneteMz0ha79KeUp6VnAvZCOVe +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/qsslsocket/certs/fake-login.live.com.pem b/tests/auto/qsslsocket/certs/fake-login.live.com.pem new file mode 100644 index 0000000..429f951 --- /dev/null +++ b/tests/auto/qsslsocket/certs/fake-login.live.com.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDjCCAnegAwIBAgIRALC3Ez7Qlvm1b66RyHS9OsAwDQYJKoZIhvcNAQEFBQAw +XjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu +dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEXMBUGA1UEAxMObG9naW4ubGl2ZS5jb20w +HhcNMTEwMzI1MTMyODUwWhcNMTEwNDI0MTMyODUwWjBeMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRcwFQYDVQQDEw5sb2dpbi5saXZlLmNvbTCBnzANBgkqhkiG9w0BAQEF +AAOBjQAwgYkCgYEAzrcXbzGtFR1EGBuau07ItSY+KihCaacmRJJrkVzotHw23dUs +BG8B6yxjLwzujjK2AW6t1gza7ZyHxfQr81DhHIfoI6+IRFUKnnFOX2+OVqK+8jXp +d/wv4MX287lx67I/4FIzYIS9otdPnNjVvoVKP7FjujrrGgU+nerO3nvmAXECAwEA +AaOByzCByDAdBgNVHQ4EFgQUpSOEcmtkQITvBdM2IDfcXnJ0FCAwgZgGA1UdIwSB +kDCBjYAUpSOEcmtkQITvBdM2IDfcXnJ0FCChYqRgMF4xCzAJBgNVBAYTAkFVMRMw +EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0 +eSBMdGQxFzAVBgNVBAMTDmxvZ2luLmxpdmUuY29tghEAsLcTPtCW+bVvrpHIdL06 +wDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAD+2HT4GSHHKCdbl9VkX +zsl+D+drMm2b0ksxz9SgPihP7aW50EEIJDEEihNMTa27mhpeOXHc/sLqDi4ECUao +/0Ns/5uoVuAIrAKCydmtPsonVFh9XWjyrfUzPOHAc9p2bmJ1i9a3kTsLB6jlrVDO +VufGzsowHlHZ0TtKf5omojU5 +-----END CERTIFICATE----- diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index ef5833ef..ccfe0f3 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -185,6 +185,7 @@ private slots: void ignoreSslErrorsListWithSlot(); void readFromClosedSocket(); void writeBigChunk(); + void blacklist(); void setEmptyDefaultConfiguration(); static void exitLoop() @@ -857,9 +858,16 @@ class SslServer : public QTcpServer { Q_OBJECT public: - SslServer() : socket(0), protocol(QSsl::TlsV1) { } + SslServer(const QString &keyFile = SRCDIR "certs/fluke.key", const QString &certFile = SRCDIR "certs/fluke.cert") + : socket(0), + protocol(QSsl::TlsV1), + m_keyFile(keyFile), + m_certFile(certFile) { } QSslSocket *socket; QSsl::SslProtocol protocol; + QString m_keyFile; + QString m_certFile; + protected: void incomingConnection(int socketDescriptor) { @@ -867,13 +875,13 @@ protected: socket->setProtocol(protocol); connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot())); - QFile file(SRCDIR "certs/fluke.key"); + QFile file(m_keyFile); QVERIFY(file.open(QIODevice::ReadOnly)); QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey); QVERIFY(!key.isNull()); socket->setPrivateKey(key); - QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert"); + QList<QSslCertificate> localCert = QSslCertificate::fromPath(m_certFile); QVERIFY(!localCert.isEmpty()); QVERIFY(localCert.first().handle()); socket->setLocalCertificate(localCert.first()); @@ -1937,6 +1945,37 @@ void tst_QSslSocket::writeBigChunk() socket->close(); } +void tst_QSslSocket::blacklist() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + SslServer server(SRCDIR "certs/fake-login.live.com.key", SRCDIR "certs/fake-login.live.com.pem"); + QSslSocket *receiver = new QSslSocket(this); + connect(receiver, SIGNAL(readyRead()), SLOT(exitLoop())); + + // connect two sockets to each other: + QVERIFY(server.listen(QHostAddress::LocalHost)); + receiver->connectToHost("127.0.0.1", server.serverPort()); + QVERIFY(receiver->waitForConnected(5000)); + QVERIFY(server.waitForNewConnection(0)); + + QSslSocket *sender = server.socket; + QVERIFY(sender); + QVERIFY(sender->state() == QAbstractSocket::ConnectedState); + receiver->setObjectName("receiver"); + sender->setObjectName("sender"); + receiver->ignoreSslErrors(); + receiver->startClientEncryption(); + + connect(receiver, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(exitLoop())); + connect(receiver, SIGNAL(encrypted()), SLOT(exitLoop())); + enterLoop(1); + QCOMPARE(receiver->error(), QAbstractSocket::SslHandshakeFailedError); + QCOMPARE(receiver->errorString(), QString("The peer certificate is blacklisted")); +} + void tst_QSslSocket::setEmptyDefaultConfiguration() { // used to produce a crash in QSslConfigurationPrivate::deepCopyDefaultConfiguration, QTBUG-13265 diff --git a/tests/auto/qtextblock/tst_qtextblock.cpp b/tests/auto/qtextblock/tst_qtextblock.cpp index cec3a6a..748d921 100644 --- a/tests/auto/qtextblock/tst_qtextblock.cpp +++ b/tests/auto/qtextblock/tst_qtextblock.cpp @@ -76,6 +76,7 @@ private slots: void excludeParagraphSeparatorFragment(); void backwardsBlockIterator(); void previousBlock_qtbug18026(); + void removedBlock_qtbug18500(); private: QTextDocument *doc; @@ -181,5 +182,16 @@ void tst_QTextBlock::previousBlock_qtbug18026() QVERIFY(last.isValid()); } +void tst_QTextBlock::removedBlock_qtbug18500() +{ + cursor.insertText("line 1\nline 2\nline 3 \nline 4\n"); + cursor.setPosition(7); + QTextBlock block = cursor.block(); + cursor.setPosition(21, QTextCursor::KeepAnchor); + + cursor.removeSelectedText(); + QVERIFY(!block.isValid()); +} + QTEST_MAIN(tst_QTextBlock) #include "tst_qtextblock.moc" diff --git a/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp index 6157004..8003c44 100644 --- a/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp +++ b/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp @@ -257,10 +257,10 @@ void tst_QTextBoundaryFinder::sentenceBoundaries() void tst_QTextBoundaryFinder::isAtWordStart() { - QString txt("The quick brown fox jumped over $the lazy. dog "); + QString txt("The quick brown fox jumped over $the lazy. dog I win!"); QList<int> start, end; - start << 0 << 4 << 10 << 16 << 20 << 27 << 32 << 33 << 37 << 41 << 43; - end << 3 << 9 << 15 << 19 << 26 << 31 << 33 << 36 << 41 << 42 << 46; + start << 0 << 4 << 10 << 16 << 20 << 27 << 32 << 33 << 37 << 41 << 43 << 48 << 50 << 53; + end << 3 << 9 << 15 << 19 << 26 << 31 << 33 << 36 << 41 << 42 << 46 << 49 << 53 << 54; QTextBoundaryFinder finder(QTextBoundaryFinder::Word, txt); for(int i=0; i < txt.length(); ++i) { finder.setPosition(i); diff --git a/tests/auto/qthread/tst_qthread.cpp b/tests/auto/qthread/tst_qthread.cpp index c69052e..7386d9d 100644 --- a/tests/auto/qthread/tst_qthread.cpp +++ b/tests/auto/qthread/tst_qthread.cpp @@ -104,6 +104,7 @@ private slots: void adoptedThreadExec(); void adoptedThreadFinished(); void adoptMultipleThreads(); + void adoptMultipleThreadsOverlap(); void QTBUG13810_exitAndStart(); void QTBUG15378_exitAndExec(); @@ -663,7 +664,9 @@ void tst_QThread::usleep() typedef void (*FunctionPointer)(void *); void noop(void*) { } -#ifdef Q_OS_UNIX +#ifdef Q_OS_SYMBIAN +typedef RThread ThreadHandle; +#elif defined Q_OS_UNIX typedef pthread_t ThreadHandle; #elif defined Q_OS_WIN typedef HANDLE ThreadHandle; @@ -694,6 +697,7 @@ public: protected: static void *runUnix(void *data); static unsigned WIN_FIX_STDCALL runWin(void *data); + static int runSymbian(void *data); FunctionPointer functionPointer; void *data; @@ -703,7 +707,10 @@ void NativeThreadWrapper::start(FunctionPointer functionPointer, void *data) { this->functionPointer = functionPointer; this->data = data; -#ifdef Q_OS_UNIX +#ifdef Q_OS_SYMBIAN + qt_symbian_throwIfError(nativeThreadHandle.Create(KNullDesC(), NativeThreadWrapper::runSymbian, 1024, &User::Allocator(), this)); + nativeThreadHandle.Resume(); +#elif defined Q_OS_UNIX const int state = pthread_create(&nativeThreadHandle, 0, NativeThreadWrapper::runUnix, this); Q_UNUSED(state); #elif defined(Q_OS_WINCE) @@ -723,7 +730,12 @@ void NativeThreadWrapper::startAndWait(FunctionPointer functionPointer, void *da void NativeThreadWrapper::join() { -#ifdef Q_OS_UNIX +#ifdef Q_OS_SYMBIAN + TRequestStatus stat; + nativeThreadHandle.Logon(stat); + User::WaitForRequest(stat); + nativeThreadHandle.Close(); +#elif defined Q_OS_UNIX pthread_join(nativeThreadHandle, 0); #elif defined Q_OS_WIN WaitForSingleObject(nativeThreadHandle, INFINITE); @@ -763,6 +775,12 @@ unsigned WIN_FIX_STDCALL NativeThreadWrapper::runWin(void *data) return 0; } +int NativeThreadWrapper::runSymbian(void *data) +{ + runUnix(data); + return 0; +} + void NativeThreadWrapper::stop() { QMutexLocker lock(&mutex); @@ -924,6 +942,7 @@ void tst_QThread::adoptMultipleThreads() for (int i = 0; i < numThreads; ++i) { nativeThreads.at(i)->stop(); nativeThreads.at(i)->join(); + delete nativeThreads.at(i); } QTestEventLoop::instance().enterLoop(5); @@ -931,6 +950,50 @@ void tst_QThread::adoptMultipleThreads() QCOMPARE(int(recorder.activationCount), numThreads); } +void tst_QThread::adoptMultipleThreadsOverlap() +{ +#if defined(Q_OS_WIN) + // Windows CE is not capable of handling that many threads. On the emulator it is dead with 26 threads already. +# if defined(Q_OS_WINCE) + const int numThreads = 20; +# else + // need to test lots of threads, so that we exceed MAXIMUM_WAIT_OBJECTS in qt_adopted_thread_watcher() + const int numThreads = 200; +# endif +#elif defined(Q_OS_SYMBIAN) + // stress the monitoring thread's add function + const int numThreads = 100; +#else + const int numThreads = 5; +#endif + QVector<NativeThreadWrapper*> nativeThreads; + + SignalRecorder recorder; + + for (int i = 0; i < numThreads; ++i) { + nativeThreads.append(new NativeThreadWrapper()); + nativeThreads.at(i)->setWaitForStop(); + nativeThreads.at(i)->mutex.lock(); + nativeThreads.at(i)->start(); + } + for (int i = 0; i < numThreads; ++i) { + nativeThreads.at(i)->startCondition.wait(&nativeThreads.at(i)->mutex); + QObject::connect(nativeThreads.at(i)->qthread, SIGNAL(finished()), &recorder, SLOT(slot())); + nativeThreads.at(i)->mutex.unlock(); + } + + QObject::connect(nativeThreads.at(numThreads - 1)->qthread, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + + for (int i = 0; i < numThreads; ++i) { + nativeThreads.at(i)->stop(); + nativeThreads.at(i)->join(); + delete nativeThreads.at(i); + } + + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + QCOMPARE(int(recorder.activationCount), numThreads); +} void tst_QThread::stressTest() { #if defined(Q_OS_WINCE) diff --git a/tests/auto/qthreadstorage/tst_qthreadstorage.cpp b/tests/auto/qthreadstorage/tst_qthreadstorage.cpp index a62bfee..2391c81 100644 --- a/tests/auto/qthreadstorage/tst_qthreadstorage.cpp +++ b/tests/auto/qthreadstorage/tst_qthreadstorage.cpp @@ -385,19 +385,18 @@ void tst_QThreadStorage::QTBUG14579_leakInDestructor() QCOMPARE(int(SPointer::count), c); } - -class QTBUG14579_reset; -Q_GLOBAL_STATIC(QThreadStorage<QTBUG14579_reset *>, QTBUG14579_resetTls) - class QTBUG14579_reset { public: SPointer member; - ~QTBUG14579_reset() { - //Quite stupid, but WTF::ThreadSpecific<T>::destroy does it. - QTBUG14579_resetTls()->setLocalData(this); - } + ~QTBUG14579_reset(); }; +Q_GLOBAL_STATIC(QThreadStorage<QTBUG14579_reset *>, QTBUG14579_resetTls) + +QTBUG14579_reset::~QTBUG14579_reset() { + //Quite stupid, but WTF::ThreadSpecific<T>::destroy does it. + QTBUG14579_resetTls()->setLocalData(this); +} void tst_QThreadStorage::QTBUG14579_resetInDestructor() { diff --git a/tests/auto/xmlpatterns/stderrBaselines/Passhelp.txt b/tests/auto/xmlpatterns/stderrBaselines/Passhelp.txt index 4e789e7..4a86f75 100644 --- a/tests/auto/xmlpatterns/stderrBaselines/Passhelp.txt +++ b/tests/auto/xmlpatterns/stderrBaselines/Passhelp.txt @@ -1,28 +1,28 @@ xmlpatterns -- A tool for running XQuery queries. - - When appearing, any following options are not + - When appearing, any following options are not interpreted as switches. -help Displays this help. - -initial-template <string> The name of the initial template to call as a + -initial-template <string> The name of the initial template to call as a Clark Name. - -is-uri If specified, all filenames on the command line + -is-uri If specified, all filenames on the command line are interpreted as URIs instead of a local filenames. - -no-format By default output is formatted for readability. + -no-format By default output is formatted for readability. When specified, strict serialization is performed. - -output <local file> A local file to which the output should be + -output <local file> A local file to which the output should be written. The file is overwritten, or if not exist, created. If absent, stdout is used. - -param <name=value> Binds an external variable. The value is + -param <name=value> Binds an external variable. The value is directly available using the variable reference: $name. -version Displays version information. - focus <string> The document to use as focus. Mandatory in case + focus <string> The document to use as focus. Mandatory in case a stylesheet is used. This option is also affected by the is-uris option. - query/stylesheet <string> A local filename pointing to the query to run. + query/stylesheet <string> A local filename pointing to the query to run. If the name ends with .xsl it's assumed to be an XSL-T stylesheet. If it ends with .xq, it's assumed to be an XQuery query. (In other cases diff --git a/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp b/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp index aa4c15a..8b38661 100644 --- a/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp +++ b/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp @@ -44,7 +44,26 @@ #include <math.h> -#ifdef Q_OS_UNIX +#ifdef Q_OS_SYMBIAN +# include <e32std.h> +typedef RMutex NativeMutexType; +void NativeMutexInitialize(NativeMutexType *mutex) +{ + mutex->CreateLocal(); +} +void NativeMutexDestroy(NativeMutexType *mutex) +{ + mutex->Close(); +} +void NativeMutexLock(NativeMutexType *mutex) +{ + mutex->Wait(); +} +void NativeMutexUnlock(NativeMutexType *mutex) +{ + mutex->Signal(); +} +#elif defined(Q_OS_UNIX) # include <pthread.h> # include <errno.h> typedef pthread_mutex_t NativeMutexType; diff --git a/tests/benchmarks/corelib/thread/qwaitcondition/qwaitcondition.pro b/tests/benchmarks/corelib/thread/qwaitcondition/qwaitcondition.pro new file mode 100644 index 0000000..bc7bd58 --- /dev/null +++ b/tests/benchmarks/corelib/thread/qwaitcondition/qwaitcondition.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_bench_qwaitcondition +QT -= gui +SOURCES += tst_qwaitcondition.cpp diff --git a/tests/benchmarks/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp b/tests/benchmarks/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp new file mode 100644 index 0000000..1bfc637 --- /dev/null +++ b/tests/benchmarks/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp @@ -0,0 +1,210 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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 <QtCore/QtCore> +#include <QtTest/QtTest> + +#include <math.h> + + +class tst_QWaitCondition : public QObject +{ + Q_OBJECT + +public: + tst_QWaitCondition() + { + } + +private slots: + void oscillate_data(); + void oscillate(); + + void thrash_data(); + void thrash(); + +public: + static QWaitCondition local, remote; + enum Turn {LocalTurn, RemoteTurn}; + static Turn turn; +}; + +QWaitCondition tst_QWaitCondition::local; +QWaitCondition tst_QWaitCondition::remote; +tst_QWaitCondition::Turn tst_QWaitCondition::turn = tst_QWaitCondition::LocalTurn; + +class OscillateThread : public QThread +{ +public: + bool m_done; + bool m_useMutex; + unsigned long m_timeout; + bool m_wakeOne; + int count; + + OscillateThread(bool useMutex, unsigned long timeout, bool wakeOne) + : m_done(false), m_useMutex(useMutex), m_timeout(timeout), m_wakeOne(wakeOne) + {} + void run() + { + QMutex mtx; + QReadWriteLock rwl; + count = 0; + + forever { + if (m_done) + break; + if (m_useMutex) { + mtx.lock(); + while (tst_QWaitCondition::turn == tst_QWaitCondition::LocalTurn) + tst_QWaitCondition::remote.wait(&mtx, m_timeout); + mtx.unlock(); + } else { + rwl.lockForWrite(); + while (tst_QWaitCondition::turn == tst_QWaitCondition::LocalTurn) + tst_QWaitCondition::remote.wait(&rwl, m_timeout); + rwl.unlock(); + } + tst_QWaitCondition::turn = tst_QWaitCondition::LocalTurn; + if (m_wakeOne) + tst_QWaitCondition::local.wakeOne(); + else + tst_QWaitCondition::local.wakeAll(); + count++; + } + } +}; + +void tst_QWaitCondition::oscillate_data() +{ + QTest::addColumn<bool>("useMutex"); + QTest::addColumn<unsigned long>("timeout"); + QTest::addColumn<bool>("wakeOne"); + + QTest::newRow("mutex, timeout, one") << true << 1000ul << true; + QTest::newRow("readWriteLock, timeout, one") << false << 1000ul << true; + QTest::newRow("mutex, timeout, all") << true << 1000ul << false; + QTest::newRow("readWriteLock, timeout, all") << false << 1000ul << false; + QTest::newRow("mutex, forever, one") << true << ULONG_MAX << true; + QTest::newRow("readWriteLock, forever, one") << false << ULONG_MAX << true; + QTest::newRow("mutex, forever, all") << true << ULONG_MAX << false; + QTest::newRow("readWriteLock, forever, all") << false << ULONG_MAX << false; +} + +void tst_QWaitCondition::oscillate() +{ + QMutex mtx; + QReadWriteLock rwl; + + QFETCH(bool, useMutex); + QFETCH(unsigned long, timeout); + QFETCH(bool, wakeOne); + + turn = LocalTurn; + OscillateThread thrd(useMutex, timeout, wakeOne); + thrd.start(); + + QBENCHMARK { + if (useMutex) + mtx.lock(); + else + rwl.lockForWrite(); + turn = RemoteTurn; + if (wakeOne) + remote.wakeOne(); + else + remote.wakeAll(); + if (useMutex) { + while (turn == RemoteTurn) + local.wait(&mtx, timeout); + mtx.unlock(); + } else { + while (turn == RemoteTurn) + local.wait(&rwl, timeout); + rwl.unlock(); + } + } + + thrd.m_done = true; + remote.wakeAll(); + thrd.wait(); + + QCOMPARE(0, 0); +} + +void tst_QWaitCondition::thrash_data() +{ + oscillate_data(); +} + +void tst_QWaitCondition::thrash() +{ + QMutex mtx; + mtx.lock(); + + QFETCH(bool, useMutex); + QFETCH(unsigned long, timeout); + QFETCH(bool, wakeOne); + + turn = LocalTurn; + OscillateThread thrd(useMutex, timeout, wakeOne); + thrd.start(); + local.wait(&mtx, 1000ul); + mtx.unlock(); + + QBENCHMARK { + turn = RemoteTurn; + if (wakeOne) + remote.wakeOne(); + else + remote.wakeAll(); + } + + thrd.m_done = true; + turn = RemoteTurn; + remote.wakeAll(); + thrd.wait(); + + QCOMPARE(0, 0); +} + +QTEST_MAIN(tst_QWaitCondition) +#include "tst_qwaitcondition.moc" |