diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-04-14 11:32:46 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-04-14 11:32:46 (GMT) |
commit | 5c4fb96fdeaf3f15e2cf31fd9970fdcfab2a8024 (patch) | |
tree | 7db123f1fac79083c96943a743ec9b491ecc8db0 /tests | |
parent | 94117641f97d180e0452c508fd4743bf29fb53a7 (diff) | |
parent | 662174b78b7e08c759d0086e215e81e9e0eaf0c5 (diff) | |
download | Qt-5c4fb96fdeaf3f15e2cf31fd9970fdcfab2a8024.zip Qt-5c4fb96fdeaf3f15e2cf31fd9970fdcfab2a8024.tar.gz Qt-5c4fb96fdeaf3f15e2cf31fd9970fdcfab2a8024.tar.bz2 |
Merge remote-tracking branch 'mainline/master'
Diffstat (limited to 'tests')
23 files changed, 496 insertions, 175 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 48466d5..7876671 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -304,8 +304,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")); } } @@ -870,7 +870,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")); @@ -895,6 +895,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); } /* @@ -1139,7 +1141,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.); @@ -1940,7 +1942,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; @@ -1953,7 +1955,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; @@ -1966,7 +1968,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; @@ -1979,7 +1981,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; @@ -1992,7 +1994,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; @@ -2005,7 +2007,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; @@ -2021,13 +2023,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; @@ -2040,13 +2042,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; @@ -2059,13 +2061,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; @@ -2077,13 +2079,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 c5a3d14..87e3347 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -248,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; 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/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/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/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/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/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/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/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 |