diff options
Diffstat (limited to 'tests')
246 files changed, 5169 insertions, 3850 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 497e720..c0004f7 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -18,6 +18,5 @@ contains(QT_CONFIG, webkit): SUBDIRS += webkit.pro contains(QT_CONFIG, multimedia): SUBDIRS += multimedia.pro contains(QT_CONFIG, phonon): SUBDIRS += phonon.pro contains(QT_CONFIG, svg): SUBDIRS += svg.pro -contains(QT_CONFIG, declarative): SUBDIRS += declarative - +contains(QT_CONFIG, declarative): SUBDIRS += declarative.pro diff --git a/tests/auto/declarative.pro b/tests/auto/declarative.pro new file mode 100644 index 0000000..f2173f0 --- /dev/null +++ b/tests/auto/declarative.pro @@ -0,0 +1,4 @@ +TEMPLATE=subdirs +SUBDIRS=\ + declarative \ + diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 143fbad..eb74244 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -1,7 +1,6 @@ TEMPLATE = subdirs SUBDIRS += \ graphicswidgets \ # Cover - layouts \ # Cover parserstress \ # Cover qmetaobjectbuilder \ # Cover qdeclarativeanimations \ # Cover @@ -29,6 +28,7 @@ SUBDIRS += \ qdeclarativeitem \ # Cover qdeclarativelistview \ # Cover qdeclarativeloader \ # Cover + qdeclarativelayouts \ # Cover qdeclarativemousearea \ # Cover qdeclarativeparticles \ # Cover qdeclarativepathview \ # Cover @@ -55,7 +55,6 @@ SUBDIRS += \ qpacketprotocol \ # Cover qdeclarativerepeater \ # Cover qdeclarativeworkerscript \ # Cover - qdeclarativeworkerlistmodel \ # Cover qdeclarativevaluetypes \ # Cover qdeclarativexmlhttprequest \ # Cover qdeclarativeimageprovider \ # Cover diff --git a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp index 9d8ba6c..6b7d57f 100644 --- a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp +++ b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp @@ -373,7 +373,6 @@ void tst_qdeclarativeanchors::crash1() QString expect = "QML Text (" + source.toString() + ":4:5" + ") Possible anchor loop detected on fill."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); // XXX ideally, should be one message QDeclarativeView *view = new QDeclarativeView(source); qApp->processEvents(); diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml b/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml index 12b1b7b..5e1891a 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml @@ -10,7 +10,7 @@ Rectangle { width: 100; height: 100 color: Qt.rgba(1,0,0) Behavior on x { - NumberAnimation { objectName: "MyAnim"; running: true } + NumberAnimation {id: myAnim; objectName: "MyAnim"; running: true } } } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml index 6419a6b..11b2d3a 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml @@ -8,8 +8,8 @@ Rectangle { width: 100; height: 100; color: "green" Behavior on x { objectName: "MyBehavior" - NumberAnimation { duration: 200 } - NumberAnimation { duration: 1000 } + NumberAnimation {id: na1; duration: 200 } + NumberAnimation {id: na2; duration: 1000 } } } MouseArea { diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml b/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml index c28fa9a..5e72bca 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml @@ -8,7 +8,7 @@ Rectangle { width: 100; height: 100; color: "green" Behavior on x { objectName: "MyBehavior"; - NumberAnimation { duration: 500; } + NumberAnimation {id: na; duration: 500; } } } MouseArea { diff --git a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp index f0117f5..be20ba1 100644 --- a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp +++ b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp @@ -58,9 +58,10 @@ private slots: void engineMethod(); void parentContext(); void setContextProperty(); - void addDefaultObject(); + void setContextObject(); void destruction(); void idAsContextProperty(); + void readOnlyContexts(); private: QDeclarativeEngine engine; @@ -224,24 +225,6 @@ private: int _c; }; -class TestObject2 : public QObject -{ - Q_OBJECT - Q_PROPERTY(int b READ b NOTIFY bChanged) - -public: - TestObject2() : _b(10) {} - - int b() const { return _b; } - void setB(int b) { _b = b; emit bChanged(); } - -signals: - void bChanged(); - -private: - int _b; -}; - #define TEST_CONTEXT_PROPERTY(ctxt, name, value) \ { \ QDeclarativeComponent component(&engine); \ @@ -367,35 +350,31 @@ void tst_qdeclarativecontext::setContextProperty() } } -void tst_qdeclarativecontext::addDefaultObject() +void tst_qdeclarativecontext::setContextObject() { QDeclarativeContext ctxt(&engine); TestObject to; - TestObject2 to2; to.setA(2); to.setB(192); to.setC(18); - to2.setB(111999); - ctxt.addDefaultObject(&to2); - ctxt.addDefaultObject(&to); + ctxt.setContextObject(&to); ctxt.setContextProperty("c", QVariant(9)); // Static context properties TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(2)); - TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(111999)); + TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(192)); TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(9)); to.setA(12); to.setB(100); to.setC(7); - to2.setB(1612); ctxt.setContextProperty("c", QVariant(3)); TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(12)); - TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(1612)); + TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(100)); TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(3)); // Changes in context properties @@ -449,6 +428,36 @@ void tst_qdeclarativecontext::idAsContextProperty() delete obj; } +// Internal contexts should be read-only +void tst_qdeclarativecontext::readOnlyContexts() +{ + QDeclarativeComponent component(&engine); + component.setData("import Qt 4.6; QtObject { id: me }", QUrl()); + + QObject *obj = component.create(); + QVERIFY(obj); + + QDeclarativeContext *context = qmlContext(obj); + QVERIFY(context); + + QVERIFY(qvariant_cast<QObject*>(context->contextProperty("me")) == obj); + QVERIFY(context->contextObject() == obj); + + QTest::ignoreMessage(QtWarningMsg, "QDeclarativeContext: Cannot set property on internal context."); + context->setContextProperty("hello", 12); + QVERIFY(context->contextProperty("hello") == QVariant()); + + QTest::ignoreMessage(QtWarningMsg, "QDeclarativeContext: Cannot set property on internal context."); + context->setContextProperty("hello", obj); + QVERIFY(context->contextProperty("hello") == QVariant()); + + QTest::ignoreMessage(QtWarningMsg, "QDeclarativeContext: Cannot set context object for internal context."); + context->setContextObject(0); + QVERIFY(context->contextObject() == obj); + + delete obj; +} + QTEST_MAIN(tst_qdeclarativecontext) #include "tst_qdeclarativecontext.moc" diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml b/tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml new file mode 100644 index 0000000..72edf6e --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +QtObject { + Component.onCompleted: { var a = getObject(); a = null; } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml new file mode 100644 index 0000000..5897e2a --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +QtObject { + property int test: getObjects().length + property bool test2: getObjects()[0].trueProperty +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp index 6a04704..a3bcb6a 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp @@ -43,7 +43,7 @@ class BaseExtensionObject : public QObject { Q_OBJECT - Q_PROPERTY(int baseExtendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged); + Q_PROPERTY(int baseExtendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged) public: BaseExtensionObject(QObject *parent) : QObject(parent), m_value(0) {} @@ -59,7 +59,7 @@ private: class ExtensionObject : public QObject { Q_OBJECT - Q_PROPERTY(int extendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged); + Q_PROPERTY(int extendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged) public: ExtensionObject(QObject *parent) : QObject(parent), m_value(0) {} @@ -74,12 +74,12 @@ private: void registerTypes() { - QML_REGISTER_TYPE(Qt.test, 1,0, MyQmlObject,MyQmlObject); - QML_REGISTER_TYPE(Qt.test, 1,0, MyDeferredObject,MyDeferredObject); - QML_REGISTER_TYPE(Qt.test, 1,0, MyQmlContainer,MyQmlContainer); - QML_REGISTER_EXTENDED_TYPE(Qt.test, 1,0, MyBaseExtendedObject,MyBaseExtendedObject,BaseExtensionObject); - QML_REGISTER_EXTENDED_TYPE(Qt.test, 1,0, MyExtendedObject,MyExtendedObject,ExtensionObject); - QML_REGISTER_TYPE(Qt.test, 1,0, MyTypeObject, MyTypeObject); + qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject"); + qmlRegisterType<MyDeferredObject>("Qt.test", 1,0, "MyDeferredObject"); + qmlRegisterType<MyQmlContainer>("Qt.test", 1,0, "MyQmlContainer"); + qmlRegisterExtendedType<MyBaseExtendedObject, BaseExtensionObject>("Qt.test", 1,0, "MyBaseExtendedObject"); + qmlRegisterExtendedType<MyExtendedObject, ExtensionObject>("Qt.test", 1,0, "MyExtendedObject"); + qmlRegisterType<MyTypeObject>("Qt.test", 1,0, "MyTypeObject"); } #include "testtypes.moc" diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index a283e3f..72dc3bb 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -205,28 +205,20 @@ public slots: class MyDefaultObject1 : public QObject { Q_OBJECT - Q_PROPERTY(int horseLegs READ horseLegs CONSTANT); - Q_PROPERTY(int antLegs READ antLegs CONSTANT); + Q_PROPERTY(int horseLegs READ horseLegs CONSTANT) + Q_PROPERTY(int antLegs READ antLegs CONSTANT) + Q_PROPERTY(int emuLegs READ emuLegs CONSTANT) public: int horseLegs() const { return 4; } int antLegs() const { return 6; } -}; - -class MyDefaultObject2 : public QObject -{ - Q_OBJECT - Q_PROPERTY(int antLegs READ antLegs CONSTANT); - Q_PROPERTY(int emuLegs READ emuLegs CONSTANT); -public: - int antLegs() const { return 5; } // Had an accident int emuLegs() const { return 2; } }; class MyDefaultObject3 : public QObject { Q_OBJECT - Q_PROPERTY(int antLegs READ antLegs CONSTANT); - Q_PROPERTY(int humanLegs READ humanLegs CONSTANT); + Q_PROPERTY(int antLegs READ antLegs CONSTANT) + Q_PROPERTY(int humanLegs READ humanLegs CONSTANT) public: int antLegs() const { return 7; } // Mutant int humanLegs() const { return 2; } @@ -237,9 +229,9 @@ class MyDeferredObject : public QObject { Q_OBJECT Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) - Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty); - Q_PROPERTY(QObject *objectProperty2 READ objectProperty2 WRITE setObjectProperty2); - Q_CLASSINFO("DeferredPropertyNames", "value,objectProperty,objectProperty2"); + Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty) + Q_PROPERTY(QObject *objectProperty2 READ objectProperty2 WRITE setObjectProperty2) + Q_CLASSINFO("DeferredPropertyNames", "value,objectProperty,objectProperty2") public: MyDeferredObject() : m_value(0), m_object(0), m_object2(0) {} @@ -266,7 +258,7 @@ QML_DECLARE_TYPE(MyDeferredObject); class MyBaseExtendedObject : public QObject { Q_OBJECT -Q_PROPERTY(int baseProperty READ baseProperty WRITE setBaseProperty); +Q_PROPERTY(int baseProperty READ baseProperty WRITE setBaseProperty) public: MyBaseExtendedObject() : m_value(0) {} @@ -281,7 +273,7 @@ QML_DECLARE_TYPE(MyBaseExtendedObject); class MyExtendedObject : public MyBaseExtendedObject { Q_OBJECT -Q_PROPERTY(int coreProperty READ coreProperty WRITE setCoreProperty); +Q_PROPERTY(int coreProperty READ coreProperty WRITE setCoreProperty) public: MyExtendedObject() : m_value(0) {} @@ -299,34 +291,34 @@ class MyTypeObject : public QObject Q_ENUMS(MyEnum) Q_FLAGS(MyFlags) - Q_PROPERTY(QString id READ id WRITE setId); - Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty); - Q_PROPERTY(QDeclarativeComponent *componentProperty READ componentProperty WRITE setComponentProperty); - Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty); - Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty); - Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty); - Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty); - Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty); - Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty); - Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty); - Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty); - Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty); - Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty); - Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty); - Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty); - Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty); - Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty); - Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty); - Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty); - Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged); - Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2); - Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty); - Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty); - Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty); - Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty); - Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty); - - Q_PROPERTY(QDeclarativeScriptString scriptProperty READ scriptProperty WRITE setScriptProperty); + Q_PROPERTY(QString id READ id WRITE setId) + Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty) + Q_PROPERTY(QDeclarativeComponent *componentProperty READ componentProperty WRITE setComponentProperty) + Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty) + Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty) + Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty) + Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty) + Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty) + Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty) + Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty) + Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty) + Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty) + Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty) + Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty) + Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty) + Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty) + Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty) + Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty) + Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty) + Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged) + Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2) + Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty) + Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty) + Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty) + Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty) + Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty) + + Q_PROPERTY(QDeclarativeScriptString scriptProperty READ scriptProperty WRITE setScriptProperty) public: MyTypeObject() diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 4838288..caefdbf 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -126,6 +126,8 @@ private slots: void attachedPropertyScope(); void scriptConnect(); void scriptDisconnect(); + void ownership(); + void qlistqobjectMethods(); void bug1(); @@ -348,7 +350,6 @@ void tst_qdeclarativeecmascript::basicExpressions() MyQmlObject object2; MyQmlObject object3; MyDefaultObject1 default1; - MyDefaultObject2 default2; MyDefaultObject3 default3; object1.setStringProperty("Object1"); object2.setStringProperty("Object2"); @@ -357,13 +358,12 @@ void tst_qdeclarativeecmascript::basicExpressions() QDeclarativeContext context(engine.rootContext()); QDeclarativeContext nestedContext(&context); - context.addDefaultObject(&default1); - context.addDefaultObject(&default2); + context.setContextObject(&default1); context.setContextProperty("a", QVariant(1944)); context.setContextProperty("b", QVariant("Milk")); context.setContextProperty("object", &object1); context.setContextProperty("objectOverride", &object2); - nestedContext.addDefaultObject(&default3); + nestedContext.setContextObject(&default3); nestedContext.setContextProperty("b", QVariant("Cow")); nestedContext.setContextProperty("objectOverride", &object3); nestedContext.setContextProperty("millipedeLegs", QVariant(100)); @@ -889,6 +889,7 @@ void tst_qdeclarativeecmascript::dynamicDestruction() } QVERIFY(!createdQmlObject); + QDeclarativeEngine::setObjectOwnership(object, QDeclarativeEngine::JavaScriptOwnership); QMetaObject::invokeMethod(object, "killMe"); QVERIFY(object); QTest::qWait(0); @@ -1636,7 +1637,7 @@ void tst_qdeclarativeecmascript::listToVariant() MyQmlContainer container; QDeclarativeContext context(engine.rootContext()); - context.addDefaultObject(&container); + context.setContextObject(&container); QObject *object = component.create(&context); QVERIFY(object != 0); @@ -1890,7 +1891,94 @@ void tst_qdeclarativeecmascript::scriptDisconnect() delete object; } +} + +class OwnershipObject : public QObject +{ + Q_OBJECT +public: + OwnershipObject() { object = new QObject; } + + QPointer<QObject> object; + +public slots: + QObject *getObject() { return object; } +}; + +void tst_qdeclarativeecmascript::ownership() +{ + OwnershipObject own; + QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext()); + context->setContextObject(&own); + + { + QDeclarativeComponent component(&engine, TEST_FILE("ownership.qml")); + + QVERIFY(own.object != 0); + + QObject *object = component.create(context); + QDeclarativeEnginePrivate::getScriptEngine(&engine)->collectGarbage(); + + QCoreApplication::processEvents(QEventLoop::DeferredDeletion); + + QVERIFY(own.object == 0); + + delete object; + } + + own.object = new QObject(&own); + + { + QDeclarativeComponent component(&engine, TEST_FILE("ownership.qml")); + + QVERIFY(own.object != 0); + + QObject *object = component.create(context); + QDeclarativeEnginePrivate::getScriptEngine(&engine)->collectGarbage(); + QCoreApplication::processEvents(QEventLoop::DeferredDeletion); + + QVERIFY(own.object != 0); + + delete object; + } +} + +class QListQObjectMethodsObject : public QObject +{ + Q_OBJECT +public: + QListQObjectMethodsObject() { + m_objects.append(new MyQmlObject()); + m_objects.append(new MyQmlObject()); + } + + ~QListQObjectMethodsObject() { + qDeleteAll(m_objects); + } + +public slots: + QList<QObject *> getObjects() { return m_objects; } + +private: + QList<QObject *> m_objects; +}; + +// Tests that returning a QList<QObject*> from a method works +void tst_qdeclarativeecmascript::qlistqobjectMethods() +{ + QListQObjectMethodsObject obj; + QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext()); + context->setContextObject(&obj); + + QDeclarativeComponent component(&engine, TEST_FILE("qlistqobjectMethods.qml")); + + QObject *object = component.create(context); + + QCOMPARE(object->property("test").toInt(), 2); + QCOMPARE(object->property("test2").toBool(), true); + + delete object; } QTEST_MAIN(tst_qdeclarativeecmascript) diff --git a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro index 0c736b4..3ba50be 100644 --- a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro +++ b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro @@ -1,8 +1,9 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui +contains(QT_CONFIG,declarative): QT += declarative gui network macx:CONFIG -= app_bundle -SOURCES += tst_qdeclarativefontloader.cpp +HEADERS += ../shared/testhttpserver.h +SOURCES += tst_qdeclarativefontloader.cpp ../shared/testhttpserver.cpp # Define SRCDIR equal to test's source directory DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp index a9762df..375e801 100644 --- a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp +++ b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp @@ -43,6 +43,9 @@ #include <QtDeclarative/qdeclarativecomponent.h> #include <private/qdeclarativefontloader_p.h> #include "../../../shared/util.h" +#include "../shared/testhttpserver.h" + +#define SERVER_PORT 14445 class tst_qdeclarativefontloader : public QObject @@ -57,16 +60,21 @@ private slots: void localFont(); void failLocalFont(); void webFont(); + void redirWebFont(); void failWebFont(); private slots: private: QDeclarativeEngine engine; + TestHTTPServer server; }; -tst_qdeclarativefontloader::tst_qdeclarativefontloader() +tst_qdeclarativefontloader::tst_qdeclarativefontloader() : + server(SERVER_PORT) { + server.serveDirectory(SRCDIR "/data"); + Q_ASSERT(server.isValid()); } void tst_qdeclarativefontloader::noFont() @@ -126,21 +134,38 @@ void tst_qdeclarativefontloader::failLocalFont() void tst_qdeclarativefontloader::webFont() { - QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://www.princexml.com/fonts/steffmann/Starburst.ttf\" }"; + QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://localhost:14445/tarzeau_ocr_a.ttf\" }"; + QDeclarativeComponent component(&engine); + + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create()); + + QVERIFY(fontObject != 0); + QVERIFY(fontObject->source() != QUrl("")); + QTRY_COMPARE(fontObject->name(), QString("OCRA")); + QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); +} + +void tst_qdeclarativefontloader::redirWebFont() +{ + server.addRedirect("olddir/oldname.ttf","../tarzeau_ocr_a.ttf"); + + QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://localhost:14445/olddir/oldname.ttf\" }"; QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create()); QVERIFY(fontObject != 0); QVERIFY(fontObject->source() != QUrl("")); - QTRY_COMPARE(fontObject->name(), QString("Starburst")); + QTRY_COMPARE(fontObject->name(), QString("OCRA")); QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); } void tst_qdeclarativefontloader::failWebFont() { - QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://wrong.address.com/Starburst.ttf\" }"; - QTest::ignoreMessage(QtWarningMsg, "Cannot load font: QUrl( \"http://wrong.address.com/Starburst.ttf\" ) "); + QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://localhost:14445/nonexist.ttf\" }"; + QTest::ignoreMessage(QtWarningMsg, "Cannot load font: QUrl( \"http://localhost:14445/nonexist.ttf\" ) "); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create()); diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml index 32833d2..cc3e549 100644 --- a/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml +++ b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml @@ -1,6 +1,7 @@ import Qt 4.6 Rectangle { + property int current: grid.currentIndex width: 240 height: 320 color: "#ffffff" diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview1.qml index ba6b807..ba6b807 100644 --- a/tests/auto/declarative/qdeclarativegridview/data/gridview.qml +++ b/tests/auto/declarative/qdeclarativegridview/data/gridview1.qml diff --git a/tests/auto/declarative/qdeclarativegridview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativegridview/data/propertychangestest.qml index da2e8d0..da2e8d0 100644 --- a/tests/auto/declarative/qdeclarativegridview/data/propertychanges.qml +++ b/tests/auto/declarative/qdeclarativegridview/data/propertychangestest.qml diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index a1edc53..dd594774 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -165,7 +165,7 @@ void tst_QDeclarativeGridView::items() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); @@ -213,7 +213,7 @@ void tst_QDeclarativeGridView::changed() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); QDeclarativeFlickable *gridview = findItem<QDeclarativeFlickable>(canvas->rootObject(), "grid"); @@ -246,7 +246,7 @@ void tst_QDeclarativeGridView::inserted() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); @@ -331,7 +331,7 @@ void tst_QDeclarativeGridView::removed() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); @@ -495,7 +495,7 @@ void tst_QDeclarativeGridView::moved() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); @@ -703,6 +703,11 @@ void tst_QDeclarativeGridView::currentIndex() QCOMPARE(gridview->highlightItem()->x(), hlPosX); QCOMPARE(gridview->highlightItem()->y(), hlPosY); + // insert item before currentIndex + gridview->setCurrentIndex(28); + model.insertItem(0, "Foo", "1111"); + QCOMPARE(canvas->rootObject()->property("current").toInt(), 29); + delete canvas; } @@ -718,7 +723,7 @@ void tst_QDeclarativeGridView::changeFlow() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); @@ -815,7 +820,7 @@ void tst_QDeclarativeGridView::propertyChanges() { QDeclarativeView *canvas = createView(); QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); QDeclarativeGridView *gridView = canvas->rootObject()->findChild<QDeclarativeGridView*>("gridView"); QVERIFY(gridView); @@ -855,7 +860,7 @@ void tst_QDeclarativeGridView::componentChanges() { QDeclarativeView *canvas = createView(); QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); QDeclarativeGridView *gridView = canvas->rootObject()->findChild<QDeclarativeGridView*>("gridView"); QVERIFY(gridView); @@ -890,7 +895,7 @@ void tst_QDeclarativeGridView::modelChanges() { QDeclarativeView *canvas = createView(); QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); QDeclarativeGridView *gridView = canvas->rootObject()->findChild<QDeclarativeGridView*>("gridView"); QVERIFY(gridView); @@ -924,7 +929,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); @@ -944,7 +949,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex() } // Position on a currently visible item - gridview->positionViewAtIndex(4); + gridview->positionViewAtIndex(4, QDeclarativeGridView::Beginning); QCOMPARE(gridview->contentY(), 60.); // Confirm items positioned correctly @@ -958,7 +963,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex() } // Position on an item beyond the visible items - gridview->positionViewAtIndex(21); + gridview->positionViewAtIndex(21, QDeclarativeGridView::Beginning); QCOMPARE(gridview->contentY(), 420.); // Confirm items positioned correctly @@ -972,7 +977,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex() } // Position on an item that would leave empty space if positioned at the top - gridview->positionViewAtIndex(31); + gridview->positionViewAtIndex(31, QDeclarativeGridView::Beginning); QCOMPARE(gridview->contentY(), 520.); // Confirm items positioned correctly @@ -986,7 +991,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex() } // Position at the beginning again - gridview->positionViewAtIndex(0); + gridview->positionViewAtIndex(0, QDeclarativeGridView::Beginning); QCOMPARE(gridview->contentY(), 0.); // Confirm items positioned correctly @@ -999,6 +1004,47 @@ void tst_QDeclarativeGridView::positionViewAtIndex() QCOMPARE(item->y(), (i/3)*60.); } + // Position at End + gridview->positionViewAtIndex(30, QDeclarativeGridView::End); + QCOMPARE(gridview->contentY(), 340.); + + // Position in Center + gridview->positionViewAtIndex(15, QDeclarativeGridView::Center); + QCOMPARE(gridview->contentY(), 170.); + + // Ensure at least partially visible + gridview->positionViewAtIndex(15, QDeclarativeGridView::Visible); + QCOMPARE(gridview->contentY(), 170.); + + gridview->setContentY(302); + gridview->positionViewAtIndex(15, QDeclarativeGridView::Visible); + QCOMPARE(gridview->contentY(), 302.); + + gridview->setContentY(360); + gridview->positionViewAtIndex(15, QDeclarativeGridView::Visible); + QCOMPARE(gridview->contentY(), 300.); + + gridview->setContentY(60); + gridview->positionViewAtIndex(20, QDeclarativeGridView::Visible); + QCOMPARE(gridview->contentY(), 60.); + + gridview->setContentY(20); + gridview->positionViewAtIndex(20, QDeclarativeGridView::Visible); + QCOMPARE(gridview->contentY(), 100.); + + // Ensure completely visible + gridview->setContentY(120); + gridview->positionViewAtIndex(20, QDeclarativeGridView::Contain); + QCOMPARE(gridview->contentY(), 120.); + + gridview->setContentY(302); + gridview->positionViewAtIndex(15, QDeclarativeGridView::Contain); + QCOMPARE(gridview->contentY(), 300.); + + gridview->setContentY(60); + gridview->positionViewAtIndex(20, QDeclarativeGridView::Contain); + QCOMPARE(gridview->contentY(), 100.); + delete canvas; } diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp index 636c5e3..5f6d9a4 100644 --- a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp +++ b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp @@ -93,7 +93,7 @@ void tst_qdeclarativeinstruction::dump() QDeclarativeInstruction i; i.line = 2; i.type = QDeclarativeInstruction::SetId; - i.setId.value = 0; + i.setId.value = data->primitives.count() - 1; i.setId.index = 0; data->bytecode << i; } @@ -171,17 +171,17 @@ void tst_qdeclarativeinstruction::dump() i.line = 10; i.type = QDeclarativeInstruction::StoreString; i.storeString.propertyIndex = 7; - i.storeString.value = 1; + i.storeString.value = data->primitives.count() - 1; data->bytecode << i; } { - data->primitives << "http://www.nokia.com"; + data->urls << QUrl("http://www.nokia.com"); QDeclarativeInstruction i; i.line = 11; i.type = QDeclarativeInstruction::StoreUrl; i.storeUrl.propertyIndex = 8; - i.storeUrl.value = 2; + i.storeUrl.value = data->urls.count() - 1; data->bytecode << i; } @@ -290,7 +290,7 @@ void tst_qdeclarativeinstruction::dump() i.line = 23; i.type = QDeclarativeInstruction::StoreVariant; i.storeString.propertyIndex = 20; - i.storeString.value = 3; + i.storeString.value = data->primitives.count() - 1; data->bytecode << i; } @@ -326,7 +326,7 @@ void tst_qdeclarativeinstruction::dump() i.line = 27; i.type = QDeclarativeInstruction::StoreSignal; i.storeSignal.signalIndex = 2; - i.storeSignal.value = 4; + i.storeSignal.value = data->primitives.count() - 1; data->bytecode << i; } @@ -527,7 +527,7 @@ void tst_qdeclarativeinstruction::dump() << "8\t\t8\tSTORE_INTEGER\t\t5\t9" << "9\t\t9\tSTORE_BOOL\t\t6\ttrue" << "10\t\t10\tSTORE_STRING\t\t7\t1\t\t\"Test String\"" - << "11\t\t11\tSTORE_URL\t\t8\t2\t\t\"http://www.nokia.com\"" + << "11\t\t11\tSTORE_URL\t\t8\t0\t\tQUrl(\"http://www.nokia.com\") " << "12\t\t12\tSTORE_COLOR\t\t9\t\t\t\"ff00ff00\"" << "13\t\t13\tSTORE_DATE\t\t10\t9" << "14\t\t14\tSTORE_TIME\t\t11\t33" @@ -539,11 +539,11 @@ void tst_qdeclarativeinstruction::dump() << "20\t\t20\tSTORE_RECT\t\t17\t2" << "21\t\t21\tSTORE_RECTF\t\t18\t19" << "22\t\t22\tSTORE_VECTOR3D\t\t19\t9" - << "23\t\t23\tSTORE_VARIANT\t\t20\t3\t\t\"color(1, 1, 1, 1)\"" + << "23\t\t23\tSTORE_VARIANT\t\t20\t2\t\t\"color(1, 1, 1, 1)\"" << "24\t\t24\tSTORE_OBJECT\t\t21" << "25\t\t25\tSTORE_VARIANT_OBJECT\t22" << "26\t\t26\tSTORE_INTERFACE\t\t23" - << "27\t\t27\tSTORE_SIGNAL\t\t2\t4\t\t\"console.log(1921)\"" + << "27\t\t27\tSTORE_SIGNAL\t\t2\t3\t\t\"console.log(1921)\"" << "28\t\t28\tSTORE_SCRIPT\t\t2" << "29\t\t29\tSTORE_SCRIPT_STRING\t24\t3\t1" << "30\t\t30\tASSIGN_SIGNAL_OBJECT\t0\t\t\t\"mySignal\"" diff --git a/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml b/tests/auto/declarative/qdeclarativeitem/data/keynavigationtest.qml index 08da901..08da901 100644 --- a/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml +++ b/tests/auto/declarative/qdeclarativeitem/data/keynavigationtest.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/keys.qml b/tests/auto/declarative/qdeclarativeitem/data/keystest.qml index 7d34fc8..7d34fc8 100644 --- a/tests/auto/declarative/qdeclarativeitem/data/keys.qml +++ b/tests/auto/declarative/qdeclarativeitem/data/keystest.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/propertychanges.qml b/tests/auto/declarative/qdeclarativeitem/data/propertychanges.qml new file mode 100644 index 0000000..bf4dd85 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeitem/data/propertychanges.qml @@ -0,0 +1,10 @@ +import Qt 4.6 + +Item { + Item { + objectName: "item" + } + Item { + objectName: "parentItem" + } +}
\ No newline at end of file diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index bbcc86e..ba69cd8 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -60,6 +60,7 @@ private slots: void clip(); void mapCoordinates(); void mapCoordinates_data(); + void propertyChanges(); private: template<typename T> @@ -119,7 +120,7 @@ void tst_QDeclarativeItem::keys() canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true)); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keys.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keystest.qml")); canvas->show(); qApp->processEvents(); @@ -214,7 +215,7 @@ void tst_QDeclarativeItem::keyNavigation() QDeclarativeView *canvas = new QDeclarativeView(0); canvas->setFixedSize(240,320); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigation.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigationtest.qml")); canvas->show(); qApp->processEvents(); @@ -289,7 +290,7 @@ void tst_QDeclarativeItem::smooth() QDeclarativeComponent component(&engine); component.setData("import Qt 4.6; Item { smooth: false; }", QUrl::fromLocalFile("")); QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); - QSignalSpy spy(item, SIGNAL(smoothChanged())); + QSignalSpy spy(item, SIGNAL(smoothChanged(bool))); QVERIFY(item); QVERIFY(!item->smooth()); @@ -297,6 +298,10 @@ void tst_QDeclarativeItem::smooth() item->setSmooth(true); QVERIFY(item->smooth()); QCOMPARE(spy.count(),1); + QList<QVariant> arguments = spy.first(); + QVERIFY(arguments.count() == 1); + QVERIFY(arguments.at(0).toBool() == true); + item->setSmooth(true); QCOMPARE(spy.count(),1); @@ -314,13 +319,18 @@ void tst_QDeclarativeItem::clip() QDeclarativeComponent component(&engine); component.setData("import Qt 4.6\nItem { clip: false\n }", QUrl::fromLocalFile("")); QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); - QSignalSpy spy(item, SIGNAL(clipChanged())); + QSignalSpy spy(item, SIGNAL(clipChanged(bool))); QVERIFY(item); QVERIFY(!item->clip()); item->setClip(true); QVERIFY(item->clip()); + + QList<QVariant> arguments = spy.first(); + QVERIFY(arguments.count() == 1); + QVERIFY(arguments.at(0).toBool() == true); + QCOMPARE(spy.count(),1); item->setClip(true); QCOMPARE(spy.count(),1); @@ -392,6 +402,84 @@ void tst_QDeclarativeItem::mapCoordinates_data() QTest::newRow(QTest::toString(i)) << i << i; } +void tst_QDeclarativeItem::propertyChanges() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setFixedSize(240,320); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + canvas->show(); + + QEvent wa(QEvent::WindowActivate); + QApplication::sendEvent(canvas, &wa); + QFocusEvent fe(QEvent::FocusIn); + QApplication::sendEvent(canvas, &fe); + + QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "item"); + QDeclarativeItem *parentItem = findItem<QDeclarativeItem>(canvas->rootObject(), "parentItem"); + + QVERIFY(item); + QVERIFY(parentItem); + + QSignalSpy parentSpy(item, SIGNAL(parentChanged(QDeclarativeItem *))); + QSignalSpy widthSpy(item, SIGNAL(widthChanged(qreal))); + QSignalSpy heightSpy(item, SIGNAL(heightChanged(qreal))); + QSignalSpy baselineOffsetSpy(item, SIGNAL(baselineOffsetChanged(qreal))); + QSignalSpy childrenRectSpy(parentItem, SIGNAL(childrenRectChanged(QRectF))); + QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool))); + QSignalSpy wantsFocusSpy(parentItem, SIGNAL(wantsFocusChanged(bool))); + + item->setParentItem(parentItem); + item->setWidth(100.0); + item->setHeight(200.0); + item->setFocus(true); + item->setBaselineOffset(10.0); + + QCOMPARE(item->parentItem(), parentItem); + QCOMPARE(parentSpy.count(),1); + QList<QVariant> parentArguments = parentSpy.first(); + QVERIFY(parentArguments.count() == 1); + QCOMPARE(item->parentItem(), qvariant_cast<QDeclarativeItem *>(parentArguments.at(0))); + + QCOMPARE(item->width(), 100.0); + QCOMPARE(widthSpy.count(),1); + QList<QVariant> widthArguments = widthSpy.first(); + QVERIFY(widthArguments.count() == 1); + QCOMPARE(item->width(), widthArguments.at(0).toReal()); + + QCOMPARE(item->height(), 200.0); + QCOMPARE(heightSpy.count(),1); + QList<QVariant> heightArguments = heightSpy.first(); + QVERIFY(heightArguments.count() == 1); + QCOMPARE(item->height(), heightArguments.at(0).toReal()); + + QCOMPARE(item->baselineOffset(), 10.0); + QCOMPARE(baselineOffsetSpy.count(),1); + QList<QVariant> baselineOffsetArguments = baselineOffsetSpy.first(); + QVERIFY(baselineOffsetArguments.count() == 1); + QCOMPARE(item->baselineOffset(), baselineOffsetArguments.at(0).toReal()); + + QCOMPARE(parentItem->childrenRect(), QRectF(0.0,0.0,100.0,200.0)); + QCOMPARE(childrenRectSpy.count(),2); + QList<QVariant> childrenRectArguments = childrenRectSpy.at(1); + QVERIFY(childrenRectArguments.count() == 1); + QCOMPARE(parentItem->childrenRect(), childrenRectArguments.at(0).toRectF()); + + QCOMPARE(item->hasFocus(), true); + QCOMPARE(focusSpy.count(),1); + QList<QVariant> focusArguments = focusSpy.first(); + QVERIFY(focusArguments.count() == 1); + QCOMPARE(focusArguments.at(0).toBool(), true); + + QCOMPARE(parentItem->hasFocus(), false); + QCOMPARE(parentItem->wantsFocus(), true); + QCOMPARE(wantsFocusSpy.count(),1); + QList<QVariant> wantsFocusArguments = wantsFocusSpy.first(); + QVERIFY(wantsFocusArguments.count() == 1); + QCOMPARE(wantsFocusArguments.at(0).toBool(), true); + + delete canvas; +} + template<typename T> T *tst_QDeclarativeItem::findItem(QGraphicsObject *parent, const QString &objectName) { diff --git a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/qmldir b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/qmldir index b32f82b..303c5c8 100644 --- a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/qmldir +++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/qmldir @@ -1,3 +1,3 @@ -Test 0.0 Test.qml -TestSubDir 0.0 TestSubDir.qml -TestLocal 0.0 TestLocal.qml +Test Test.qml +TestSubDir TestSubDir.qml +TestLocal TestLocal.qml diff --git a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/qmldir b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/qmldir index f7016c7..a54f7df 100644 --- a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/qmldir +++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/qmldir @@ -1 +1 @@ -SubTest 0.0 SubTest.qml +SubTest SubTest.qml diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp index 9ffe28a..6efe755 100644 --- a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp @@ -42,15 +42,15 @@ void registerTypes() { - QML_REGISTER_INTERFACE(MyInterface); - QML_REGISTER_TYPE(Test,1,0,MyQmlObject,MyQmlObject); - QML_REGISTER_TYPE(Test,1,0,MyTypeObject,MyTypeObject); - QML_REGISTER_TYPE(Test,1,0,MyContainer,MyContainer); - QML_REGISTER_TYPE(Test,1,0,MyPropertyValueSource,MyPropertyValueSource); - QML_REGISTER_TYPE(Test,1,0,MyDotPropertyObject,MyDotPropertyObject); - QML_REGISTER_TYPE(Test,1,0,MyNamespacedType,MyNamespace::MyNamespacedType); - QML_REGISTER_TYPE(Test,1,0,MySecondNamespacedType,MyNamespace::MySecondNamespacedType); - QML_REGISTER_NOCREATE_TYPE(MyGroupedObject); + qmlRegisterInterface<MyInterface>("MyInterface"); + qmlRegisterType<MyQmlObject>("Test",1,0,"MyQmlObject"); + qmlRegisterType<MyTypeObject>("Test",1,0,"MyTypeObject"); + qmlRegisterType<MyContainer>("Test",1,0,"MyContainer"); + qmlRegisterType<MyPropertyValueSource>("Test",1,0,"MyPropertyValueSource"); + qmlRegisterType<MyDotPropertyObject>("Test",1,0,"MyDotPropertyObject"); + qmlRegisterType<MyNamespace::MyNamespacedType>("Test",1,0,"MyNamespacedType"); + qmlRegisterType<MyNamespace::MySecondNamespacedType>("Test",1,0,"MySecondNamespacedType"); + qmlRegisterType<MyGroupedObject>(); } QVariant myCustomVariantTypeConverter(const QString &data) diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h index df93dc8..4963e2e 100644 --- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h +++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h @@ -106,8 +106,8 @@ class MyQmlObject : public QObject, public MyInterface, public QDeclarativeParse Q_PROPERTY(QRect rect READ rect WRITE setRect) Q_PROPERTY(QMatrix matrix READ matrix WRITE setMatrix) //assumed to be unsupported by QML Q_PROPERTY(MyInterface *interfaceProperty READ interface WRITE setInterface) - Q_PROPERTY(int onLiteralSignal READ onLiteralSignal WRITE setOnLiteralSignal); - Q_PROPERTY(MyCustomVariantType customType READ customType WRITE setCustomType); + Q_PROPERTY(int onLiteralSignal READ onLiteralSignal WRITE setOnLiteralSignal) + Q_PROPERTY(MyCustomVariantType customType READ customType WRITE setCustomType) Q_PROPERTY(MyQmlObject *qmlobjectProperty READ qmlobject WRITE setQmlobject) Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal) @@ -135,7 +135,7 @@ public: static MyAttachedObject *qmlAttachedProperties(QObject *other) { return new MyAttachedObject(other); } - Q_CLASSINFO("DefaultMethod", "basicSlot()"); + Q_CLASSINFO("DefaultMethod", "basicSlot()") int onLiteralSignal() const { return m_value; } void setOnLiteralSignal(int v) { m_value = v; } @@ -171,8 +171,8 @@ QML_DECLARE_TYPE(MyQmlObject); class MyGroupedObject : public QObject { Q_OBJECT - Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript); - Q_PROPERTY(int value READ value WRITE setValue); + Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript) + Q_PROPERTY(int value READ value WRITE setValue) public: QDeclarativeScriptString script() const { return m_script; } void setScript(const QDeclarativeScriptString &s) { m_script = s; } @@ -194,36 +194,36 @@ class MyTypeObject : public QObject Q_ENUMS(MyEnum) Q_FLAGS(MyFlags) - Q_PROPERTY(QString id READ id WRITE setId); - Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty); - Q_PROPERTY(QDeclarativeComponent *componentProperty READ componentProperty WRITE setComponentProperty); - Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty); - Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty); - Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty); - Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty); - Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty); - Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty); - Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty); - Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty); - Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty); - Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty); - Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty); - Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty); - Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty); - Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty); - Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty); - Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty); - Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged); - Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2); - Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty); - Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty); - Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty); - Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty); - Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty); - - Q_PROPERTY(QDeclarativeScriptString scriptProperty READ scriptProperty WRITE setScriptProperty); - Q_PROPERTY(MyGroupedObject *grouped READ grouped CONSTANT); - Q_PROPERTY(MyGroupedObject *nullGrouped READ nullGrouped CONSTANT); + Q_PROPERTY(QString id READ id WRITE setId) + Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty) + Q_PROPERTY(QDeclarativeComponent *componentProperty READ componentProperty WRITE setComponentProperty) + Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty) + Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty) + Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty) + Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty) + Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty) + Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty) + Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty) + Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty) + Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty) + Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty) + Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty) + Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty) + Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty) + Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty) + Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty) + Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty) + Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged) + Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2) + Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty) + Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty) + Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty) + Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty) + Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty) + + Q_PROPERTY(QDeclarativeScriptString scriptProperty READ scriptProperty WRITE setScriptProperty) + Q_PROPERTY(MyGroupedObject *grouped READ grouped CONSTANT) + Q_PROPERTY(MyGroupedObject *nullGrouped READ nullGrouped CONSTANT) public: MyTypeObject() @@ -467,7 +467,7 @@ class MyContainer : public QObject Q_OBJECT Q_PROPERTY(QDeclarativeListProperty<QObject> children READ children) Q_PROPERTY(QDeclarativeListProperty<MyInterface> qlistInterfaces READ qlistInterfaces) - Q_CLASSINFO("DefaultProperty", "children"); + Q_CLASSINFO("DefaultProperty", "children") public: MyContainer() {} @@ -549,7 +549,7 @@ namespace MyNamespace { class MySecondNamespacedType : public QObject { Q_OBJECT - Q_PROPERTY(QDeclarativeListProperty<MyNamespace::MyNamespacedType> list READ list); + Q_PROPERTY(QDeclarativeListProperty<MyNamespace::MyNamespacedType> list READ list) public: QDeclarativeListProperty<MyNamespacedType> list() { return QDeclarativeListProperty<MyNamespacedType>(this, m_list); } diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 083c551..6b564d4 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -1418,12 +1418,12 @@ void tst_qdeclarativelanguage::initTestCase() { registerTypes(); - QML_REGISTER_TYPE(com.nokia.Test, 0, 0, TestTP, TestType); - QML_REGISTER_TYPE(com.nokia.Test, 1, 0, Test, TestType); - QML_REGISTER_TYPE(com.nokia.Test, 1, 5, Test, TestType); - QML_REGISTER_TYPE(com.nokia.Test, 1, 8, Test, TestType2); - QML_REGISTER_TYPE(com.nokia.Test, 1, 9, OldTest, TestType); - QML_REGISTER_TYPE(com.nokia.Test, 1, 12, Test, TestType2); + qmlRegisterType<TestType>("com.nokia.Test", 0, 0, "TestTP"); + qmlRegisterType<TestType>("com.nokia.Test", 1, 0, "Test"); + qmlRegisterType<TestType>("com.nokia.Test", 1, 5, "Test"); + qmlRegisterType<TestType2>("com.nokia.Test", 1, 8, "Test"); + qmlRegisterType<TestType>("com.nokia.Test", 1, 9, "OldTest"); + qmlRegisterType<TestType2>("com.nokia.Test", 1, 12, "Test"); // Create locale-specific file // For POSIX, this will just be data/I18nType.qml, since POSIX is 7-bit diff --git a/tests/auto/declarative/layouts/data/layouts.qml b/tests/auto/declarative/qdeclarativelayouts/data/layouts.qml index 1792500..1792500 100644 --- a/tests/auto/declarative/layouts/data/layouts.qml +++ b/tests/auto/declarative/qdeclarativelayouts/data/layouts.qml diff --git a/tests/auto/declarative/layouts/layouts.pro b/tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro index f38e155..7276162 100644 --- a/tests/auto/declarative/layouts/layouts.pro +++ b/tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro @@ -1,6 +1,6 @@ load(qttest_p4) contains(QT_CONFIG,declarative): QT += declarative -SOURCES += tst_layouts.cpp +SOURCES += tst_qdeclarativelayouts.cpp macx:CONFIG -= app_bundle # Define SRCDIR equal to test's source directory diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/qdeclarativelayouts/tst_qdeclarativelayouts.cpp index 942125f..879047e 100644 --- a/tests/auto/declarative/layouts/tst_layouts.cpp +++ b/tests/auto/declarative/qdeclarativelayouts/tst_qdeclarativelayouts.cpp @@ -144,4 +144,4 @@ QDeclarativeView *tst_QDeclarativeLayouts::createView(const QString &filename) QTEST_MAIN(tst_QDeclarativeLayouts) -#include "tst_layouts.moc" +#include "tst_qdeclarativelayouts.moc" diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/model.qml b/tests/auto/declarative/qdeclarativelistmodel/data/model.qml new file mode 100644 index 0000000..ebd4ebf --- /dev/null +++ b/tests/auto/declarative/qdeclarativelistmodel/data/model.qml @@ -0,0 +1,22 @@ +import Qt 4.6 + +Item { + id: item + property var model + property bool done: false + property var result + + function evalExpressionViaWorker(commands) { + done = false + worker.sendMessage({'commands': commands, 'model': model}) + } + + WorkerScript { + id: worker + source: "script.js" + onMessage: { + item.result = messageObject.result + item.done = true + } + } +} diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/script.js b/tests/auto/declarative/qdeclarativelistmodel/data/script.js new file mode 100644 index 0000000..66a4acb --- /dev/null +++ b/tests/auto/declarative/qdeclarativelistmodel/data/script.js @@ -0,0 +1,13 @@ +WorkerScript.onMessage = function(msg) { + var result = null + try { + for (var i=0; i<msg.commands.length; i++) { + var c = 'msg.model.' + msg.commands[i] + result = eval(c) + } + msg.model.sync() + } catch(e) { } + WorkerScript.sendMessage({'done': true, 'result': result}) +} + + diff --git a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro index d728d08..8813242 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro +++ b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro @@ -4,3 +4,6 @@ QT += script macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativelistmodel.cpp + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index a1e6d6b..7a10ad0 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -39,10 +39,16 @@ ** ****************************************************************************/ #include <qtest.h> +#include <QtDeclarative/private/qdeclarativeitem_p.h> +#include <QtDeclarative/private/qdeclarativetext_p.h> #include <QtDeclarative/private/qdeclarativelistmodel_p.h> #include <QtDeclarative/private/qdeclarativeexpression_p.h> #include <QDeclarativeComponent> -#include <QDebug> + +#include <QtCore/qtimer.h> +#include <QtCore/qdebug.h> + +#include "../../../shared/util.h" class tst_QDeclarativeListModel : public QObject { @@ -50,6 +56,11 @@ class tst_QDeclarativeListModel : public QObject public: tst_QDeclarativeListModel() {} +private: + QScriptValue nestedListValue(QScriptEngine *eng) const; + QDeclarativeItem *createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarativeListModel *model); + void waitForWorker(QDeclarativeItem *item); + private slots: void static_types(); void static_types_data(); @@ -58,10 +69,50 @@ private slots: void static_nestedElements_data(); void dynamic_data(); void dynamic(); + void dynamic_worker_data(); + void dynamic_worker(); + void convertNestedToFlat_fail(); + void convertNestedToFlat_fail_data(); + void convertNestedToFlat_ok(); + void convertNestedToFlat_ok_data(); void error_data(); void error(); }; +QScriptValue tst_QDeclarativeListModel::nestedListValue(QScriptEngine *eng) const +{ + QScriptValue list = eng->newArray(); + list.setProperty(0, eng->newObject()); + list.setProperty(1, eng->newObject()); + QScriptValue sv = eng->newObject(); + sv.setProperty("foo", list); + return sv; +} + +QDeclarativeItem *tst_QDeclarativeListModel::createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarativeListModel *model) +{ + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component->create()); + QDeclarativeEngine::setContextForObject(model, eng->rootContext()); + if (item) + item->setProperty("model", qVariantFromValue(model)); + return item; +} + +void tst_QDeclarativeListModel::waitForWorker(QDeclarativeItem *item) +{ + QEventLoop loop; + QTimer timer; + timer.setSingleShot(true); + connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + + QDeclarativeProperty prop(item, "done"); + QVERIFY(prop.isValid()); + QVERIFY(prop.connectNotifySignal(&loop, SLOT(quit()))); + timer.start(10000); + loop.exec(); + QVERIFY(timer.isActive()); +} + void tst_QDeclarativeListModel::static_i18n() { QString expect = QString::fromUtf8("na\303\257ve"); @@ -149,10 +200,10 @@ void tst_QDeclarativeListModel::dynamic_data() QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << ""; QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << ""; QTest::newRow("remove3") << "{append({'foo':123});remove(0);get(0).foo}" << 0 << "QML ListModel (unknown location) get: index 0 out of range"; - QTest::newRow("remove3a") << "{append({'foo':123});remove(-1)}" << 0 << "QML ListModel (unknown location) remove: index -1 out of range"; + QTest::newRow("remove3a") << "{append({'foo':123});remove(-1);count}" << 1 << "QML ListModel (unknown location) remove: index -1 out of range"; QTest::newRow("remove4a") << "{remove(0)}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range"; - QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0)}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range"; - QTest::newRow("remove4c") << "{append({'foo':123});remove(1)}" << 0 << "QML ListModel (unknown location) remove: index 1 out of range"; + QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0);count}" << 0 << "QML ListModel (unknown location) remove: index 0 out of range"; + QTest::newRow("remove4c") << "{append({'foo':123});remove(1);count}" << 1 << "QML ListModel (unknown location) remove: index 1 out of range"; QTest::newRow("insert1") << "{insert(0,{'foo':123});count}" << 1 << ""; QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << "QML ListModel (unknown location) insert: index 1 out of range"; @@ -161,7 +212,7 @@ void tst_QDeclarativeListModel::dynamic_data() QTest::newRow("insert3c") << "{append({'foo':123});insert(1,{'foo':456});get(1).foo}" << 456 << ""; QTest::newRow("insert3d") << "{append({'foo':123});insert(0,{'foo':456});get(0).foo}" << 456 << ""; QTest::newRow("insert3e") << "{append({'foo':123});insert(0,{'foo':456});get(1).foo}" << 123 << ""; - QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456})}" << 0 << "QML ListModel (unknown location) insert: index -1 out of range"; + QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456});count}" << 1 << "QML ListModel (unknown location) insert: index -1 out of range"; QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << "QML ListModel (unknown location) insert: value is not an object"; QTest::newRow("insert5b") << "{insert(0,[1,2,3])}" << 0 << "QML ListModel (unknown location) insert: value is not an object"; @@ -171,8 +222,8 @@ void tst_QDeclarativeListModel::dynamic_data() QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << ""; QTest::newRow("set4a") << "{set(0,{'foo':456})}" << 0 << "QML ListModel (unknown location) set: index 0 out of range"; QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << "QML ListModel (unknown location) set: index -1 out of range"; - QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123)}" << 0 << "QML ListModel (unknown location) set: value is not an object"; - QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3])}" << 0 << "QML ListModel (unknown location) set: value is not an object"; + QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123);count}" << 1 << "QML ListModel (unknown location) set: value is not an object"; + QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3]);count}" << 1 << "QML ListModel (unknown location) set: value is not an object"; QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << ""; QTest::newRow("setprop1") << "{append({'foo':123});setProperty(0,'foo',456);count}" << 1 << ""; @@ -181,7 +232,7 @@ void tst_QDeclarativeListModel::dynamic_data() QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).bar}" << 456 << ""; QTest::newRow("setprop4a") << "{setProperty(0,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 0 out of range"; QTest::newRow("setprop4b") << "{setProperty(-1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index -1 out of range"; - QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456)}" << 0 << "QML ListModel (unknown location) set: index 1 out of range"; + QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456);count}" << 1 << "QML ListModel (unknown location) set: index 1 out of range"; QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});setProperty(1,'bar',222);get(1).bar}" << 222 << ""; QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << ""; @@ -193,16 +244,22 @@ void tst_QDeclarativeListModel::dynamic_data() QTest::newRow("move2b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(0).foo}" << 789 << ""; QTest::newRow("move2c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(1).foo}" << 123 << ""; QTest::newRow("move2d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(2).foo}" << 456 << ""; - QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3)}" << 0 << "QML ListModel (unknown location) move: out of range"; - QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1)}" << 0 << "QML ListModel (unknown location) move: out of range"; - QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1)}" << 0 << "QML ListModel (unknown location) move: out of range"; - QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1)}" << 0 << "QML ListModel (unknown location) move: out of range"; + QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3);count}" << 3 << "QML ListModel (unknown location) move: out of range"; + QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1);count}" << 3 << "QML ListModel (unknown location) move: out of range"; + QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1);count}" << 3 << "QML ListModel (unknown location) move: out of range"; + QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1);count}" << 3 << "QML ListModel (unknown location) move: out of range"; + + // Nested models - // Structured model + QTest::newRow("nested-append1") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});count}" << 1 << ""; + QTest::newRow("nested-append2") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.get(1).a}" << 2 << ""; + QTest::newRow("nested-append3") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.append({'a':4});get(0).bars.get(3).a}" << 4 << ""; - QTest::newRow("listprop1a") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});count}" << 1 << ""; - QTest::newRow("listprop1b") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.get(1).a}" << 2 << ""; - QTest::newRow("listprop2a") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.append({'a':4});get(0).bars.get(3).a}" << 4 << ""; + QTest::newRow("nested-insert") << "{append({'foo':123});insert(0,{'bars':[{'a':1},{'b':2},{'c':3}]});get(0).bars.get(0).a}" << 1 << ""; + QTest::newRow("nested-set") << "{append({'foo':123});set(0,{'foo':[{'x':123}]});get(0).foo.get(0).x}" << 123 << ""; + + // XXX + //QTest::newRow("nested-setprop") << "{append({'foo':123});setProperty(0,'foo',[{'x':123}]);get(0).foo.get(0).x}" << 123 << ""; } void tst_QDeclarativeListModel::dynamic() @@ -214,10 +271,11 @@ void tst_QDeclarativeListModel::dynamic() QDeclarativeEngine engine; QDeclarativeListModel model; QDeclarativeEngine::setContextForObject(&model,engine.rootContext()); - engine.rootContext()->addDefaultObject(&model); + engine.rootContext()->setContextObject(&model); QDeclarativeExpression e(engine.rootContext(), script, &model); if (!warning.isEmpty()) QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); + int actual = e.value().toInt(); if (e.hasError()) qDebug() << e.error(); // errors not expected @@ -225,6 +283,161 @@ void tst_QDeclarativeListModel::dynamic() QCOMPARE(actual,result); } +void tst_QDeclarativeListModel::dynamic_worker_data() +{ + dynamic_data(); +} + +void tst_QDeclarativeListModel::dynamic_worker() +{ + QSKIP("Skip, awaiting imminent fixes", SkipAll); + + QFETCH(QString, script); + QFETCH(int, result); + QFETCH(QString, warning); + + QDeclarativeListModel model; + QDeclarativeEngine eng; + QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); + QVERIFY(item != 0); + + if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}')) + script = script.mid(1, script.length() - 2); + QVariantList operations; + foreach (const QString &s, script.split(';')) { + if (!s.isEmpty()) + operations << s; + } + + if (!warning.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); + + if (operations.count() == 1) { + // test count(), get() return the correct default values in the worker list model + QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", + Q_ARG(QVariant, operations))); + waitForWorker(item); + QCOMPARE(QDeclarativeProperty(item, "result").read().toInt(), result); + } else { + // execute a set of commands on the worker list model, then check the + // changes are reflected in the list model in the main thread + if (QByteArray(QTest::currentDataTag()).startsWith("nested")) + QTest::ignoreMessage(QtWarningMsg, "QML ListModel (unknown location) Cannot add nested list values when modifying or after modification from a worker script"); + QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", + Q_ARG(QVariant, operations.mid(0, operations.length()-1)))); + waitForWorker(item); + + QDeclarativeExpression e(eng.rootContext(), operations.last().toString(), &model); + if (QByteArray(QTest::currentDataTag()).startsWith("nested")) + QVERIFY(e.value().toInt() != result); + else + QCOMPARE(e.value().toInt(), result); + } + + delete item; + QTest::ignoreMessage(QtWarningMsg, "QThread: Destroyed while thread is still running"); + qApp->processEvents(); +} + +void tst_QDeclarativeListModel::convertNestedToFlat_fail() +{ + QSKIP("Skip, awaiting imminent fixes", SkipAll); + // If a model has nested data, it cannot be used at all from a worker script + + QFETCH(QString, script); + + QDeclarativeListModel model; + QDeclarativeEngine eng; + QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); + QVERIFY(item != 0); + + QScriptEngine s_eng; + QScriptValue plainData = s_eng.newObject(); + plainData.setProperty("foo", QScriptValue(123)); + model.append(plainData); + model.append(nestedListValue(&s_eng)); + QCOMPARE(model.count(), 2); + + QTest::ignoreMessage(QtWarningMsg, "QML ListModel (unknown location) List contains nested list values and cannot be used from a worker script"); + QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", Q_ARG(QVariant, script))); + waitForWorker(item); + + QCOMPARE(model.count(), 2); + + delete item; + QTest::ignoreMessage(QtWarningMsg, "QThread: Destroyed while thread is still running"); + qApp->processEvents(); +} + +void tst_QDeclarativeListModel::convertNestedToFlat_fail_data() +{ + QTest::addColumn<QString>("script"); + + QTest::newRow("clear") << "clear()"; + QTest::newRow("remove") << "remove(0)"; + QTest::newRow("append") << "append({'x':1})"; + QTest::newRow("insert") << "insert(0, {'x':1})"; + QTest::newRow("set") << "set(0, {'foo':1})"; + QTest::newRow("setProperty") << "setProperty(0, 'foo', 1})"; + QTest::newRow("move") << "move(0, 1, 1})"; + QTest::newRow("get") << "get(0)"; +} + +void tst_QDeclarativeListModel::convertNestedToFlat_ok() +{ + // If a model only has plain data, it can be modified from a worker script. However, + // once the model is used from a worker script, it no longer accepts nested data + + QSKIP("Skip, awaiting imminent fixes", SkipAll); + + QFETCH(QString, script); + + QDeclarativeListModel model; + QDeclarativeEngine eng; + QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); + QVERIFY(item != 0); + + QScriptEngine s_eng; + QScriptValue plainData = s_eng.newObject(); + plainData.setProperty("foo", QScriptValue(123)); + model.append(plainData); + QCOMPARE(model.count(), 1); + + QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", Q_ARG(QVariant, script))); + waitForWorker(item); + + // can still add plain data + int count = model.count(); + model.append(plainData); + QCOMPARE(model.count(), count+1); + + QScriptValue nested = nestedListValue(&s_eng); + const char *warning = "QML ListModel (unknown location) Cannot add nested list values when modifying or after modification from a worker script"; + + QTest::ignoreMessage(QtWarningMsg, warning); + model.append(nested); + + QTest::ignoreMessage(QtWarningMsg, warning); + model.insert(0, nested); + + QTest::ignoreMessage(QtWarningMsg, warning); + model.set(0, nested); + + QCOMPARE(model.count(), count+1); + + delete item; + QTest::ignoreMessage(QtWarningMsg, "QThread: Destroyed while thread is still running"); + qApp->processEvents(); +} + +void tst_QDeclarativeListModel::convertNestedToFlat_ok_data() +{ + convertNestedToFlat_fail_data(); +} + void tst_QDeclarativeListModel::static_types_data() { QTest::addColumn<QString>("qml"); @@ -252,7 +465,7 @@ void tst_QDeclarativeListModel::static_types_data() QTest::newRow("enum") << "ListElement { foo: Text.AlignHCenter }" - << QVariant("QTBUG-5974:ListElement: constant script support for property value"); + << QVariant(double(QDeclarativeText::AlignHCenter)); } void tst_QDeclarativeListModel::static_types() @@ -309,7 +522,7 @@ void tst_QDeclarativeListModel::error_data() QTest::newRow("bindings not allowed in ListElement") << "import Qt 4.6\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }" - << "ListElement: cannot use script for property value"; // but note QTBUG-5974 + << "ListElement: cannot use script for property value"; QTest::newRow("random object list properties allowed in ListElement") << "import Qt 4.6\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }" diff --git a/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp b/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp index 1b7af19..908f336 100644 --- a/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp +++ b/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp @@ -91,8 +91,8 @@ private slots: class TestType : public QObject { Q_OBJECT - Q_PROPERTY(QDeclarativeListProperty<TestType> data READ dataProperty); - Q_PROPERTY(int intProperty READ intProperty); + Q_PROPERTY(QDeclarativeListProperty<TestType> data READ dataProperty) + Q_PROPERTY(int intProperty READ intProperty) public: TestType() : property(this, data) {} @@ -106,7 +106,7 @@ QML_DECLARE_TYPE(TestType); void tst_qdeclarativelistreference::initTestCase() { - QML_REGISTER_NOCREATE_TYPE(TestType); + qmlRegisterType<TestType>(); } void tst_qdeclarativelistreference::qmllistreference() diff --git a/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml b/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml index 74f5ef4..a6d7610 100644 --- a/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml +++ b/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml @@ -1,6 +1,7 @@ import Qt 4.6 Rectangle { + property int current: list.currentIndex width: 240 height: 320 color: "#ffffff" diff --git a/tests/auto/declarative/qdeclarativelistview/data/listview.qml b/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml index 1c1b3f8..1c1b3f8 100644 --- a/tests/auto/declarative/qdeclarativelistview/data/listview.qml +++ b/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativelistview/data/propertychangestest.qml index a41f003..a41f003 100644 --- a/tests/auto/declarative/qdeclarativelistview/data/propertychanges.qml +++ b/tests/auto/declarative/qdeclarativelistview/data/propertychangestest.qml diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 75fbbf8..8d94804 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -321,7 +321,7 @@ void tst_QDeclarativeListView::items() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); @@ -402,7 +402,7 @@ void tst_QDeclarativeListView::changed() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); QDeclarativeFlickable *listview = findItem<QDeclarativeFlickable>(canvas->rootObject(), "list"); @@ -438,7 +438,7 @@ void tst_QDeclarativeListView::inserted() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); @@ -531,7 +531,7 @@ void tst_QDeclarativeListView::removed(bool animated) testObject->setAnimate(animated); ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); @@ -673,7 +673,7 @@ void tst_QDeclarativeListView::clear() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); @@ -710,7 +710,7 @@ void tst_QDeclarativeListView::moved() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); @@ -851,7 +851,7 @@ void tst_QDeclarativeListView::spacing() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); @@ -925,6 +925,7 @@ void tst_QDeclarativeListView::sections() // Remove section boundary model.removeItem(5); + QTest::qWait(100); // New section header created QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 5); @@ -932,6 +933,7 @@ void tst_QDeclarativeListView::sections() QCOMPARE(item->height(), 40.0); model.insertItem(3, "New Item", "0"); + QTest::qWait(100); // Section header moved item = findItem<QDeclarativeItem>(viewport, "wrapper", 5); @@ -944,6 +946,7 @@ void tst_QDeclarativeListView::sections() // insert item which will become a section header model.insertItem(6, "Replace header", "1"); + QTest::qWait(100); item = findItem<QDeclarativeItem>(viewport, "wrapper", 6); QVERIFY(item); @@ -1056,6 +1059,11 @@ void tst_QDeclarativeListView::currentIndex() QTest::qWait(500); QCOMPARE(listview->highlightItem()->y(), hlPos); + // insert item before currentIndex + listview->setCurrentIndex(28); + model.insertItem(0, "Foo", "1111"); + QCOMPARE(canvas->rootObject()->property("current").toInt(), 29); + delete canvas; } @@ -1114,7 +1122,7 @@ void tst_QDeclarativeListView::cacheBuffer() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); @@ -1166,7 +1174,7 @@ void tst_QDeclarativeListView::positionViewAtIndex() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); @@ -1185,7 +1193,7 @@ void tst_QDeclarativeListView::positionViewAtIndex() } // Position on a currently visible item - listview->positionViewAtIndex(3); + listview->positionViewAtIndex(3, QDeclarativeListView::Beginning); QCOMPARE(listview->contentY(), 60.); // Confirm items positioned correctly @@ -1198,7 +1206,7 @@ void tst_QDeclarativeListView::positionViewAtIndex() } // Position on an item beyond the visible items - listview->positionViewAtIndex(22); + listview->positionViewAtIndex(22, QDeclarativeListView::Beginning); QCOMPARE(listview->contentY(), 440.); // Confirm items positioned correctly @@ -1211,7 +1219,7 @@ void tst_QDeclarativeListView::positionViewAtIndex() } // Position on an item that would leave empty space if positioned at the top - listview->positionViewAtIndex(28); + listview->positionViewAtIndex(28, QDeclarativeListView::Beginning); QCOMPARE(listview->contentY(), 480.); // Confirm items positioned correctly @@ -1224,7 +1232,7 @@ void tst_QDeclarativeListView::positionViewAtIndex() } // Position at the beginning again - listview->positionViewAtIndex(0); + listview->positionViewAtIndex(0, QDeclarativeListView::Beginning); QCOMPARE(listview->contentY(), 0.); // Confirm items positioned correctly @@ -1236,6 +1244,47 @@ void tst_QDeclarativeListView::positionViewAtIndex() QCOMPARE(item->y(), i*20.); } + // Position at End + listview->positionViewAtIndex(20, QDeclarativeListView::End); + QCOMPARE(listview->contentY(), 100.); + + // Position in Center + listview->positionViewAtIndex(15, QDeclarativeListView::Center); + QCOMPARE(listview->contentY(), 150.); + + // Ensure at least partially visible + listview->positionViewAtIndex(15, QDeclarativeListView::Visible); + QCOMPARE(listview->contentY(), 150.); + + listview->setContentY(302); + listview->positionViewAtIndex(15, QDeclarativeListView::Visible); + QCOMPARE(listview->contentY(), 302.); + + listview->setContentY(320); + listview->positionViewAtIndex(15, QDeclarativeListView::Visible); + QCOMPARE(listview->contentY(), 300.); + + listview->setContentY(85); + listview->positionViewAtIndex(20, QDeclarativeListView::Visible); + QCOMPARE(listview->contentY(), 85.); + + listview->setContentY(75); + listview->positionViewAtIndex(20, QDeclarativeListView::Visible); + QCOMPARE(listview->contentY(), 100.); + + // Ensure completely visible + listview->setContentY(120); + listview->positionViewAtIndex(20, QDeclarativeListView::Contain); + QCOMPARE(listview->contentY(), 120.); + + listview->setContentY(302); + listview->positionViewAtIndex(15, QDeclarativeListView::Contain); + QCOMPARE(listview->contentY(), 300.); + + listview->setContentY(85); + listview->positionViewAtIndex(20, QDeclarativeListView::Contain); + QCOMPARE(listview->contentY(), 100.); + delete canvas; } @@ -1284,7 +1333,7 @@ void tst_QDeclarativeListView::propertyChanges() { QDeclarativeView *canvas = createView(); QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); QDeclarativeListView *listView = canvas->rootObject()->findChild<QDeclarativeListView*>("listView"); QVERIFY(listView); @@ -1352,7 +1401,7 @@ void tst_QDeclarativeListView::componentChanges() { QDeclarativeView *canvas = createView(); QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); QDeclarativeListView *listView = canvas->rootObject()->findChild<QDeclarativeListView*>("listView"); QVERIFY(listView); @@ -1400,7 +1449,7 @@ void tst_QDeclarativeListView::modelChanges() { QDeclarativeView *canvas = createView(); QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); QDeclarativeListView *listView = canvas->rootObject()->findChild<QDeclarativeListView*>("listView"); QVERIFY(listView); diff --git a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp index 818f108..36efe13 100644 --- a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp +++ b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp @@ -77,9 +77,9 @@ private slots: class TestType : public QObject { Q_OBJECT - Q_PROPERTY(int foo READ foo); + Q_PROPERTY(int foo READ foo) - Q_CLASSINFO("DefaultProperty", "foo"); + Q_CLASSINFO("DefaultProperty", "foo") public: int foo() { return 0; } }; @@ -88,7 +88,7 @@ QML_DECLARE_TYPE(TestType); class ParserStatusTestType : public QObject, public QDeclarativeParserStatus { Q_OBJECT - Q_CLASSINFO("DefaultProperty", "foo"); // Missing default property + Q_CLASSINFO("DefaultProperty", "foo") // Missing default property }; QML_DECLARE_TYPE(ParserStatusTestType); @@ -132,10 +132,10 @@ QML_DECLARE_TYPE(ValueInterceptorTestType); void tst_qdeclarativemetatype::initTestCase() { - QML_REGISTER_TYPE(Test, 1, 0, TestType, TestType); - QML_REGISTER_TYPE(Test, 1, 0, ParserStatusTestType, ParserStatusTestType); - QML_REGISTER_TYPE(Test, 1, 0, ValueSourceTestType, ValueSourceTestType); - QML_REGISTER_TYPE(Test, 1, 0, ValueInterceptorTestType, ValueInterceptorTestType); + qmlRegisterType<TestType>("Test", 1, 0, "TestType"); + qmlRegisterType<ParserStatusTestType>("Test", 1, 0, "ParserStatusTestType"); + qmlRegisterType<ValueSourceTestType>("Test", 1, 0, "ValueSourceTestType"); + qmlRegisterType<ValueInterceptorTestType>("Test", 1, 0, "ValueInterceptorTestType"); } void tst_qdeclarativemetatype::copy() diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp index 92f7aef..1335c7c 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp @@ -101,10 +101,13 @@ inline QUrl TEST_FILE(const QString &filename) void tst_qdeclarativemoduleplugin::importsPlugin() { +QSKIP("Fix me", SkipAll); QDeclarativeEngine engine; QTest::ignoreMessage(QtWarningMsg, "plugin created"); QTest::ignoreMessage(QtWarningMsg, "import worked"); QDeclarativeComponent component(&engine, TEST_FILE("plugin.qml")); + foreach (QDeclarativeError err, component.errors()) + qWarning() << err; VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); diff --git a/tests/auto/declarative/qdeclarativeparticles/data/particlemotion.qml b/tests/auto/declarative/qdeclarativeparticles/data/particlemotiontest.qml index ace61fe..f1e4909 100644 --- a/tests/auto/declarative/qdeclarativeparticles/data/particlemotion.qml +++ b/tests/auto/declarative/qdeclarativeparticles/data/particlemotiontest.qml @@ -1,10 +1,12 @@ import Qt 4.6 +import Qt.labs.particles 1.0 + Rectangle { width: 240 height: 320 color: "black" Particles { - objectName: "particles" + objectName: "particles" anchors.fill: parent width: 1 height: 1 @@ -30,4 +32,4 @@ Rectangle { pace: 100 } ] -}
\ No newline at end of file +} diff --git a/tests/auto/declarative/qdeclarativeparticles/data/particles.qml b/tests/auto/declarative/qdeclarativeparticles/data/particlestest.qml index 0d42645..4f168a9 100644 --- a/tests/auto/declarative/qdeclarativeparticles/data/particles.qml +++ b/tests/auto/declarative/qdeclarativeparticles/data/particlestest.qml @@ -1,4 +1,6 @@ import Qt 4.6 +import Qt.labs.particles 1.0 + Rectangle{ width: 100 height: 100 @@ -7,7 +9,7 @@ Rectangle{ Particles { id: particles objectName: "particles" width:1; height:1; anchors.centerIn: parent; opacity: 1 - lifeSpan: 100; lifeSpanDeviation: 20; count:1000; + lifeSpan: 100; lifeSpanDeviation: 20; count:1000; fadeInDuration: 20; fadeOutDuration: 20; emissionRate: 1000 angle: 0; angleDeviation: 360; velocity: 500; velocityDeviation:30 source: "particle.png" diff --git a/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp b/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp index 6090a07..093190c 100644 --- a/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp +++ b/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp @@ -41,7 +41,7 @@ #include <QtTest/QtTest> #include <QtTest/QSignalSpy> #include <qdeclarativeview.h> -#include <private/qdeclarativeparticles_p.h> +#include <QGraphicsObject> class tst_QDeclarativeParticles : public QObject { @@ -65,75 +65,77 @@ tst_QDeclarativeParticles::tst_QDeclarativeParticles() void tst_QDeclarativeParticles::properties() { - QDeclarativeView *canvas = createView(SRCDIR "/data/particles.qml"); + QDeclarativeView *canvas = createView(SRCDIR "/data/particlestest.qml"); QVERIFY(canvas->rootObject()); - QDeclarativeParticles* particles = canvas->rootObject()->findChild<QDeclarativeParticles*>("particles"); + + QObject* particles = canvas->rootObject()->findChild<QObject*>("particles"); QVERIFY(particles); - particles->setSource(QUrl::fromLocalFile(SRCDIR "/data/particle.png")); - QCOMPARE(particles->source(), QUrl::fromLocalFile(SRCDIR "/data/particle.png")); + particles->setProperty("source", QUrl::fromLocalFile(SRCDIR "/data/particle.png")); + QCOMPARE(particles->property("source").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/particle.png")); - particles->setLifeSpanDeviation(1000); - QCOMPARE(particles->lifeSpanDeviation(), 1000); + particles->setProperty("lifeSpanDeviation", (1000)); + QCOMPARE(particles->property("lifeSpanDeviation").toInt(), 1000); - particles->setFadeInDuration(1000); - QCOMPARE(particles->fadeInDuration(), 1000); + particles->setProperty("fadeInDuration", 1000); + QCOMPARE(particles->property("fadeInDuration").toInt(), 1000); - particles->setFadeOutDuration(1000); - QCOMPARE(particles->fadeOutDuration(), 1000); + particles->setProperty("fadeOutDuration", 1000); + QCOMPARE(particles->property("fadeOutDuration").toInt(), 1000); - particles->setAngle(100.0); - QCOMPARE(particles->angle(), 100.0); + particles->setProperty("angle", 100.0); + QCOMPARE(particles->property("angle").toDouble(), 100.0); - particles->setAngleDeviation(100.0); - QCOMPARE(particles->angleDeviation(), 100.0); + particles->setProperty("angleDeviation", 100.0); + QCOMPARE(particles->property("angleDeviation").toDouble(), 100.0); - particles->setVelocity(100.0); - QCOMPARE(particles->velocity(), 100.0); + particles->setProperty("velocity", 100.0); + QCOMPARE(particles->property("velocity").toDouble(), 100.0); - particles->setVelocityDeviation(100.0); - QCOMPARE(particles->velocityDeviation(), 100.0); + particles->setProperty("velocityDeviation", 100.0); + QCOMPARE(particles->property("velocityDeviation").toDouble(), 100.0); - particles->setEmissionVariance(0.5); - QCOMPARE(particles->emissionVariance(),0.5); + particles->setProperty("emissionVariance", 0.5); + QCOMPARE(particles->property("emissionVariance").toDouble(),0.5); - particles->setEmissionRate(12); - QCOMPARE(particles->emissionRate(), 12); + particles->setProperty("emissionRate", 12); + QCOMPARE(particles->property("emissionRate").toInt(), 12); } void tst_QDeclarativeParticles::motionGravity() { - QDeclarativeView *canvas = createView(SRCDIR "/data/particlemotion.qml"); + QDeclarativeView *canvas = createView(SRCDIR "/data/particlemotiontest.qml"); QVERIFY(canvas->rootObject()); - QDeclarativeParticles* particles = canvas->rootObject()->findChild<QDeclarativeParticles*>("particles"); + + QObject* particles = canvas->rootObject()->findChild<QObject*>("particles"); QVERIFY(particles); - QDeclarativeParticleMotionGravity* motionGravity = canvas->rootObject()->findChild<QDeclarativeParticleMotionGravity*>("motionGravity"); - QCOMPARE(particles->motion(), motionGravity); + QObject* motionGravity = canvas->rootObject()->findChild<QObject*>("motionGravity"); + //QCOMPARE(qvariant_cast<QObject*>(particles->property("motion")), motionGravity); QSignalSpy xattractorSpy(motionGravity, SIGNAL(xattractorChanged())); QSignalSpy yattractorSpy(motionGravity, SIGNAL(yattractorChanged())); QSignalSpy accelerationSpy(motionGravity, SIGNAL(accelerationChanged())); - QCOMPARE(motionGravity->xAttractor(), 0.0); - QCOMPARE(motionGravity->yAttractor(), 1000.0); - QCOMPARE(motionGravity->acceleration(), 25.0); + QCOMPARE(motionGravity->property("xattractor").toDouble(), 0.0); + QCOMPARE(motionGravity->property("yattractor").toDouble(), 1000.0); + QCOMPARE(motionGravity->property("acceleration").toDouble(), 25.0); - motionGravity->setXAttractor(20.0); - motionGravity->setYAttractor(10.0); - motionGravity->setAcceleration(10.0); + motionGravity->setProperty("xattractor", 20.0); + motionGravity->setProperty("yattractor", 10.0); + motionGravity->setProperty("acceleration", 10.0); - QCOMPARE(motionGravity->xAttractor(), 20.0); - QCOMPARE(motionGravity->yAttractor(), 10.0); - QCOMPARE(motionGravity->acceleration(), 10.0); + QCOMPARE(motionGravity->property("xattractor").toDouble(), 20.0); + QCOMPARE(motionGravity->property("yattractor").toDouble(), 10.0); + QCOMPARE(motionGravity->property("acceleration").toDouble(), 10.0); QCOMPARE(xattractorSpy.count(), 1); QCOMPARE(yattractorSpy.count(), 1); QCOMPARE(accelerationSpy.count(), 1); - motionGravity->setXAttractor(20.0); - motionGravity->setYAttractor(10.0); - motionGravity->setAcceleration(10.0); + motionGravity->setProperty("xattractor", 20.0); + motionGravity->setProperty("yattractor", 10.0); + motionGravity->setProperty("acceleration", 10.0); QCOMPARE(xattractorSpy.count(), 1); QCOMPARE(yattractorSpy.count(), 1); @@ -142,44 +144,46 @@ void tst_QDeclarativeParticles::motionGravity() void tst_QDeclarativeParticles::motionWander() { - QDeclarativeView *canvas = createView(SRCDIR "/data/particlemotion.qml"); + QDeclarativeView *canvas = createView(SRCDIR "/data/particlemotiontest.qml"); QVERIFY(canvas->rootObject()); - QDeclarativeParticles* particles = canvas->rootObject()->findChild<QDeclarativeParticles*>("particles"); + + QObject* particles = canvas->rootObject()->findChild<QObject*>("particles"); QVERIFY(particles); - + QSignalSpy motionSpy(particles, SIGNAL(motionChanged())); - QDeclarativeParticleMotionWander* motionWander = canvas->rootObject()->findChild<QDeclarativeParticleMotionWander*>("motionWander"); - - particles->setMotion(motionWander); - QCOMPARE(particles->motion(),motionWander); - QCOMPARE(motionSpy.count(), 1); - - particles->setMotion(motionWander); - QCOMPARE(motionSpy.count(), 1); + QObject* motionWander = canvas->rootObject()->findChild<QObject*>("motionWander"); + + QCOMPARE(motionSpy.count(), 0); + particles->setProperty("motion", QVariant::fromValue(motionWander)); + //QCOMPARE(particles->property("motion"), QVariant::fromValue(motionWander)); + //QCOMPARE(motionSpy.count(), 1); + + particles->setProperty("motion", QVariant::fromValue(motionWander)); + //QCOMPARE(motionSpy.count(), 1); QSignalSpy xvarianceSpy(motionWander, SIGNAL(xvarianceChanged())); QSignalSpy yvarianceSpy(motionWander, SIGNAL(yvarianceChanged())); QSignalSpy paceSpy(motionWander, SIGNAL(paceChanged())); - QCOMPARE(motionWander->xVariance(), 30.0); - QCOMPARE(motionWander->yVariance(), 30.0); - QCOMPARE(motionWander->pace(), 100.0); + QCOMPARE(motionWander->property("xvariance").toDouble(), 30.0); + QCOMPARE(motionWander->property("yvariance").toDouble(), 30.0); + QCOMPARE(motionWander->property("pace").toDouble(), 100.0); - motionWander->setXVariance(20.0); - motionWander->setYVariance(10.0); - motionWander->setPace(10.0); + motionWander->setProperty("xvariance", 20.0); + motionWander->setProperty("yvariance", 10.0); + motionWander->setProperty("pace", 10.0); - QCOMPARE(motionWander->xVariance(), 20.0); - QCOMPARE(motionWander->yVariance(), 10.0); - QCOMPARE(motionWander->pace(), 10.0); + QCOMPARE(motionWander->property("xvariance").toDouble(), 20.0); + QCOMPARE(motionWander->property("yvariance").toDouble(), 10.0); + QCOMPARE(motionWander->property("pace").toDouble(), 10.0); QCOMPARE(xvarianceSpy.count(), 1); QCOMPARE(yvarianceSpy.count(), 1); QCOMPARE(paceSpy.count(), 1); - motionWander->setXVariance(20.0); - motionWander->setYVariance(10.0); - motionWander->setPace(10.0); + QCOMPARE(motionWander->property("xvariance").toDouble(), 20.0); + QCOMPARE(motionWander->property("yvariance").toDouble(), 10.0); + QCOMPARE(motionWander->property("pace").toDouble(), 10.0); QCOMPARE(xvarianceSpy.count(), 1); QCOMPARE(yvarianceSpy.count(), 1); @@ -188,9 +192,10 @@ void tst_QDeclarativeParticles::motionWander() void tst_QDeclarativeParticles::runs() { - QDeclarativeView *canvas = createView(SRCDIR "/data/particles.qml"); + QDeclarativeView *canvas = createView(SRCDIR "/data/particlestest.qml"); QVERIFY(canvas->rootObject()); - QDeclarativeParticles* particles = canvas->rootObject()->findChild<QDeclarativeParticles*>("particles"); + + QObject* particles = canvas->rootObject()->findChild<QObject*>("particles"); QVERIFY(particles); QTest::qWait(1000);//Run for one second. Test passes if it doesn't crash. } diff --git a/tests/auto/declarative/qdeclarativepathview/data/path.qml b/tests/auto/declarative/qdeclarativepathview/data/pathtest.qml index 7e82a48..7e82a48 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/path.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathtest.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml index ae0c86a..ae0c86a 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathview.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml index f8ed29f..70cfbcd 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml @@ -2,7 +2,7 @@ import Qt 4.6 PathView { id: photoPathView - y: 100; width: 800; height: 330; pathItemCount: 4; offset: 10 + y: 100; width: 800; height: 330; pathItemCount: 4; offset: 0.1 dragMargin: 24; snapPosition: 0.50 path: Path { diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index 62eb8c3..c16c46f 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -213,7 +213,7 @@ void tst_QDeclarativePathView::items() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview0.qml")); qApp->processEvents(); QDeclarativePathView *pathview = findItem<QDeclarativePathView>(canvas->rootObject(), "view"); @@ -262,7 +262,7 @@ void tst_QDeclarativePathView::pathview3() QVERIFY(obj->delegate() != 0); QVERIFY(obj->model() != QVariant()); QCOMPARE(obj->currentIndex(), 0); - QCOMPARE(obj->offset(), 50.); // ??? + QCOMPARE(obj->offset(), 0.5); // ??? QCOMPARE(obj->snapPosition(), 0.5); // ??? QCOMPARE(obj->dragMargin(), 24.); QCOMPARE(obj->count(), 8); @@ -272,7 +272,7 @@ void tst_QDeclarativePathView::pathview3() void tst_QDeclarativePathView::path() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/path.qml")); + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathtest.qml")); QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create()); QVERIFY(obj != 0); @@ -407,7 +407,7 @@ void tst_QDeclarativePathView::pathMoved() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview0.qml")); qApp->processEvents(); QDeclarativePathView *pathview = findItem<QDeclarativePathView>(canvas->rootObject(), "view"); @@ -422,14 +422,14 @@ void tst_QDeclarativePathView::pathMoved() offset.setX(firstItem->width()/2); offset.setY(firstItem->height()/2); QCOMPARE(firstItem->pos() + offset, start); - pathview->setOffset(10); + pathview->setOffset(0.1); for(int i=0; i<model.count(); i++){ QDeclarativeRectangle *curItem = findItem<QDeclarativeRectangle>(pathview, "wrapper", i); QCOMPARE(curItem->pos() + offset, path->pointAt(0.1 + i*0.25)); } - pathview->setOffset(100); + pathview->setOffset(1.0); QCOMPARE(firstItem->pos() + offset, start); delete canvas; @@ -448,7 +448,7 @@ void tst_QDeclarativePathView::setCurrentIndex() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview0.qml")); qApp->processEvents(); QDeclarativePathView *pathview = findItem<QDeclarativePathView>(canvas->rootObject(), "view"); diff --git a/tests/auto/declarative/qdeclarativepositioners/data/grid.qml b/tests/auto/declarative/qdeclarativepositioners/data/gridtest.qml index 830df6a..830df6a 100644 --- a/tests/auto/declarative/qdeclarativepositioners/data/grid.qml +++ b/tests/auto/declarative/qdeclarativepositioners/data/gridtest.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/propertychanges.qml b/tests/auto/declarative/qdeclarativepositioners/data/propertychangestest.qml index 4370a18..4370a18 100644 --- a/tests/auto/declarative/qdeclarativepositioners/data/propertychanges.qml +++ b/tests/auto/declarative/qdeclarativepositioners/data/propertychangestest.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/repeater.qml b/tests/auto/declarative/qdeclarativepositioners/data/repeatertest.qml index 2bc5e94..2bc5e94 100644 --- a/tests/auto/declarative/qdeclarativepositioners/data/repeater.qml +++ b/tests/auto/declarative/qdeclarativepositioners/data/repeatertest.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index d23d74c..0e1fee2 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -239,7 +239,7 @@ void tst_QDeclarativePositioners::test_vertical_animated() void tst_QDeclarativePositioners::test_grid() { - QDeclarativeView *canvas = createView(SRCDIR "/data/grid.qml"); + QDeclarativeView *canvas = createView(SRCDIR "/data/gridtest.qml"); QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one"); QVERIFY(one != 0); @@ -365,9 +365,10 @@ void tst_QDeclarativePositioners::test_grid_animated() } void tst_QDeclarativePositioners::test_propertychanges() { - QDeclarativeView *canvas = createView(SRCDIR "/data/propertychanges.qml"); + QDeclarativeView *canvas = createView(SRCDIR "/data/propertychangestest.qml"); QDeclarativeGrid *grid = qobject_cast<QDeclarativeGrid*>(canvas->rootObject()); + QVERIFY(grid != 0); QDeclarativeTransition *rowTransition = canvas->rootObject()->findChild<QDeclarativeTransition*>("rowTransition"); QDeclarativeTransition *columnTransition = canvas->rootObject()->findChild<QDeclarativeTransition*>("columnTransition"); @@ -421,7 +422,7 @@ void tst_QDeclarativePositioners::test_propertychanges() void tst_QDeclarativePositioners::test_repeater() { - QDeclarativeView *canvas = createView(SRCDIR "/data/repeater.qml"); + QDeclarativeView *canvas = createView(SRCDIR "/data/repeatertest.qml"); QDeclarativeRectangle *one = canvas->rootObject()->findChild<QDeclarativeRectangle*>("one"); QVERIFY(one != 0); diff --git a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp index 9b8a643..eed12ea 100644 --- a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp +++ b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp @@ -183,15 +183,15 @@ void tst_qdeclarativeproperty::qmlmetaproperty() class PropertyObject : public QObject { Q_OBJECT - Q_PROPERTY(int defaultProperty READ defaultProperty); - Q_PROPERTY(QRect rectProperty READ rectProperty); - Q_PROPERTY(QRect wrectProperty READ wrectProperty WRITE setWRectProperty); - Q_PROPERTY(QUrl url READ url WRITE setUrl); - Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty); + Q_PROPERTY(int defaultProperty READ defaultProperty) + Q_PROPERTY(QRect rectProperty READ rectProperty) + Q_PROPERTY(QRect wrectProperty READ wrectProperty WRITE setWRectProperty) + Q_PROPERTY(QUrl url READ url WRITE setUrl) + Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty) Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal) - Q_PROPERTY(MyQmlObject *qmlObject READ qmlObject); + Q_PROPERTY(MyQmlObject *qmlObject READ qmlObject) - Q_CLASSINFO("DefaultProperty", "defaultProperty"); + Q_CLASSINFO("DefaultProperty", "defaultProperty") public: PropertyObject() : m_resetProperty(9) {} @@ -1348,9 +1348,9 @@ void tst_qdeclarativeproperty::copy() void tst_qdeclarativeproperty::initTestCase() { - QML_REGISTER_TYPE(Test,1,0,MyQmlObject,MyQmlObject); - QML_REGISTER_TYPE(Test,1,0,PropertyObject,PropertyObject); - QML_REGISTER_TYPE(Test,1,0,MyContainer,MyContainer); + qmlRegisterType<MyQmlObject>("Test",1,0,"MyQmlObject"); + qmlRegisterType<PropertyObject>("Test",1,0,"PropertyObject"); + qmlRegisterType<MyContainer>("Test",1,0,"MyContainer"); } diff --git a/tests/auto/declarative/qdeclarativeqt/data/closestangle.qml b/tests/auto/declarative/qdeclarativeqt/data/closestangle.qml deleted file mode 100644 index b5f7fc6..0000000 --- a/tests/auto/declarative/qdeclarativeqt/data/closestangle.qml +++ /dev/null @@ -1,12 +0,0 @@ -import Qt 4.6 - -QtObject { - property var testSame: Qt.closestAngle(0,1) - property var testLess: Qt.closestAngle(0,-359) - property var testMore: Qt.closestAngle(0,361) - property var testFail: Qt.closestAngle(0) - property var test5: Qt.closestAngle(0,1,2) - property var test6: Qt.closestAngle(123.45465768,1.11) - property var test7: Qt.closestAngle(-3.1415,1.11) -} - diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index b70011b..debec02 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -66,7 +66,6 @@ private slots: void lighter(); void darker(); void tint(); - void closestAngle(); void openUrlExternally(); void md5(); void createComponent(); @@ -262,23 +261,6 @@ void tst_qdeclarativeqt::tint() delete object; } -void tst_qdeclarativeqt::closestAngle() -{ - QDeclarativeComponent component(&engine, TEST_FILE("closestangle.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); - - QCOMPARE(qvariant_cast<qreal>(object->property("testSame")), 1.0); - QCOMPARE(qvariant_cast<qreal>(object->property("testLess")), 1.0); - QCOMPARE(qvariant_cast<qreal>(object->property("testMore")), 1.0); - QCOMPARE(qvariant_cast<qreal>(object->property("testFail")), 0.0); - QCOMPARE(qvariant_cast<qreal>(object->property("test5")), 1.0); - QCOMPARE(qvariant_cast<qreal>(object->property("test6")), 1.11); - QCOMPARE(qvariant_cast<qreal>(object->property("test7")), 1.11); - - delete object; -} - void tst_qdeclarativeqt::openUrlExternally() { QEXPECT_FAIL("", "How do we test this?", Abort); diff --git a/tests/auto/declarative/qdeclarativerepeater/data/repeater.qml b/tests/auto/declarative/qdeclarativerepeater/data/repeater1.qml index 7d83230..7d83230 100644 --- a/tests/auto/declarative/qdeclarativerepeater/data/repeater.qml +++ b/tests/auto/declarative/qdeclarativerepeater/data/repeater1.qml diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp index 7a97e60..09c4879 100644 --- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp +++ b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp @@ -109,7 +109,7 @@ public: setRoleNames(roles); } - int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); } + int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); } QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const { QVariant rv; if (role == Name) @@ -224,7 +224,7 @@ void tst_QDeclarativeRepeater::stringList() QDeclarativeContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testData", data); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater1.qml")); qApp->processEvents(); QDeclarativeRepeater *repeater = findItem<QDeclarativeRepeater>(canvas->rootObject(), "repeater"); diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChanges.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges1.qml index 7dce889..7dce889 100644 --- a/tests/auto/declarative/qdeclarativestates/data/anchorChanges.qml +++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges1.qml diff --git a/tests/auto/declarative/qdeclarativestates/data/parentChange.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange1.qml index b8c7818..b8c7818 100644 --- a/tests/auto/declarative/qdeclarativestates/data/parentChange.qml +++ b/tests/auto/declarative/qdeclarativestates/data/parentChange1.qml diff --git a/tests/auto/declarative/qdeclarativestates/data/reset.qml b/tests/auto/declarative/qdeclarativestates/data/reset.qml index a0a2b8c..8e9b13a 100644 --- a/tests/auto/declarative/qdeclarativestates/data/reset.qml +++ b/tests/auto/declarative/qdeclarativestates/data/reset.qml @@ -5,9 +5,9 @@ Rectangle { height: 480 Text { id: theText - width: 50 + width: 40 wrap: true - text: "a text string that is longer than 50 pixels" + text: "a text string that is longer than 40 pixels" } states: State { diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index 8d3ca7a..fe7ec15 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -110,7 +110,7 @@ private slots: void tst_qdeclarativestates::initTestCase() { - QML_REGISTER_TYPE(Qt.test, 1, 0, MyRectangle,MyRect); + qmlRegisterType<MyRect>("Qt.test", 1, 0, "MyRectangle"); } QByteArray tst_qdeclarativestates::fullDataPath(const QString &path) @@ -441,7 +441,7 @@ void tst_qdeclarativestates::parentChange() QDeclarativeEngine engine; { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange.qml"); + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange1.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); QVERIFY(rect != 0); @@ -546,7 +546,7 @@ void tst_qdeclarativestates::anchorChanges() { QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges.qml"); + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges1.qml"); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); QVERIFY(rect != 0); @@ -955,12 +955,12 @@ void tst_qdeclarativestates::reset() QDeclarativeText *text = rect->findChild<QDeclarativeText*>(); QVERIFY(text != 0); - QCOMPARE(text->width(), qreal(50.)); + QCOMPARE(text->width(), qreal(40.)); QVERIFY(text->width() < text->height()); rect->setState("state1"); - QVERIFY(text->width() > 51); + QVERIFY(text->width() > 41); QVERIFY(text->width() > text->height()); } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.1.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.1.qml new file mode 100644 index 0000000..2697bb5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.1.qml @@ -0,0 +1,42 @@ +import Qt 4.6 + +Rectangle { + id: root + + width: 800 + height: 600 + + property alias font: myText.font + + property int myPixelSize: 12 + property int myPixelSize2: 24 + + Text { + id: other + font.pixelSize: 6 + } + + Text { + id: myText + + text: "Hello world!" + font.pixelSize: myPixelSize + } + + states: State { + name: "Swapped" + PropertyChanges { + target: myText + font: other.font + } + } + + function toggle() { + if (root.state == "") root.state = "Swapped"; else root.state = ""; + } + + MouseArea { + anchors.fill: parent + onClicked: { if (root.state == "") root.state = "Swapped"; else root.state = "";} + } +} diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.2.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.2.qml new file mode 100644 index 0000000..478104e1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.2.qml @@ -0,0 +1,42 @@ +import Qt 4.6 + +Rectangle { + id: root + + width: 800 + height: 600 + + property alias font: myText.font + + property int myPixelSize: 12 + property int myPixelSize2: 24 + + Text { + id: other + font.pixelSize: 6 + } + + Text { + id: myText + + text: "Hello world!" + font: other.font + } + + states: State { + name: "Swapped" + PropertyChanges { + target: myText + font.pixelSize: myPixelSize + } + } + + function toggle() { + if (root.state == "") root.state = "Swapped"; else root.state = ""; + } + + MouseArea { + anchors.fill: parent + onClicked: { if (root.state == "") root.state = "Swapped"; else root.state = "";} + } +} diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.3.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.3.qml new file mode 100644 index 0000000..d35c72e --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.3.qml @@ -0,0 +1,42 @@ +import Qt 4.6 + +Rectangle { + id: root + + width: 800 + height: 600 + + property alias font: myText.font + + property int myPixelSize: 12 + property int myPixelSize2: 24 + + Text { + id: other + font.pixelSize: 6 + } + + Text { + id: myText + + text: "Hello world!" + font.pixelSize: myPixelSize + } + + states: State { + name: "Swapped" + PropertyChanges { + target: myText + font.pixelSize: myPixelSize2 + } + } + + function toggle() { + if (root.state == "") root.state = "Swapped"; else root.state = ""; + } + + MouseArea { + anchors.fill: parent + onClicked: { if (root.state == "") root.state = "Swapped"; else root.state = "";} + } +} diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp index aa8bd6e..e30a319 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp @@ -42,7 +42,7 @@ void registerTypes() { - QML_REGISTER_TYPE(Test, 1, 0, MyTypeObject, MyTypeObject); - QML_REGISTER_TYPE(Test, 1, 0, MyConstantValueSource, MyConstantValueSource); - QML_REGISTER_TYPE(Test, 1, 0, MyOffsetValueInterceptor, MyOffsetValueInterceptor); + qmlRegisterType<MyTypeObject>("Test", 1, 0, "MyTypeObject"); + qmlRegisterType<MyConstantValueSource>("Test", 1, 0, "MyConstantValueSource"); + qmlRegisterType<MyOffsetValueInterceptor>("Test", 1, 0, "MyOffsetValueInterceptor"); } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h index dfc2829..0ad8449 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h +++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h @@ -59,14 +59,14 @@ class MyTypeObject : public QObject { Q_OBJECT - Q_PROPERTY(QPoint point READ point WRITE setPoint NOTIFY changed); - Q_PROPERTY(QPointF pointf READ pointf WRITE setPointf NOTIFY changed); - Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY changed); - Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed); - Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed); - Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed); - Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed); - Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed); + Q_PROPERTY(QPoint point READ point WRITE setPoint NOTIFY changed) + Q_PROPERTY(QPointF pointf READ pointf WRITE setPointf NOTIFY changed) + Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY changed) + Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed) + Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed) + Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed) + Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed) + Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed) public: MyTypeObject() : diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 51f9a07..a5cb16f 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -77,6 +77,7 @@ private slots: void scriptVariantCopy(); void cppClasses(); void enums(); + void conflictingBindings(); private: QDeclarativeEngine engine; @@ -314,8 +315,17 @@ void tst_qdeclarativevaluetypes::font() font.setLetterSpacing(QFont::AbsoluteSpacing, 9.7); font.setWordSpacing(11.2); - QEXPECT_FAIL("", "QT-2920", Continue); - QCOMPARE(object->font(), font); + QFont f = object->font(); + QCOMPARE(f.family(), font.family()); + QCOMPARE(f.bold(), font.bold()); + QCOMPARE(f.weight(), font.weight()); + QCOMPARE(f.italic(), font.italic()); + QCOMPARE(f.underline(), font.underline()); + QCOMPARE(f.strikeOut(), font.strikeOut()); + QCOMPARE(f.pointSize(), font.pointSize()); + QCOMPARE(f.capitalization(), font.capitalization()); + QCOMPARE(f.letterSpacing(), font.letterSpacing()); + QCOMPARE(f.wordSpacing(), font.wordSpacing()); delete object; } @@ -422,12 +432,13 @@ void tst_qdeclarativevaluetypes::autoBindingRemoval() object->setProperty("value", QVariant(92)); - QEXPECT_FAIL("", "QT-2920", Continue); + //QEXPECT_FAIL("", "QT-2920", Continue); QCOMPARE(object->rect().x(), 42); delete object; } + /* { QDeclarativeComponent component(&engine, TEST_FILE("autoBindingRemoval.2.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); @@ -465,12 +476,11 @@ void tst_qdeclarativevaluetypes::autoBindingRemoval() object->setProperty("value", QVariant(QRect(19, 3, 4, 8))); - QEXPECT_FAIL("", "QT-2920", Continue); QCOMPARE(object->rect(), QRect(44, 22, 33, 44)); delete object; } - +*/ } // Test that property value sources assign to value types @@ -626,6 +636,65 @@ void tst_qdeclarativevaluetypes::enums() } } +// Tests switching between "conflicting" bindings (eg. a binding on the core +// property, to a binding on the value-type sub-property) +void tst_qdeclarativevaluetypes::conflictingBindings() +{ + { + QDeclarativeComponent component(&engine, TEST_FILE("conflicting.1.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12); + + QMetaObject::invokeMethod(object, "toggle"); + + QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6); + + QMetaObject::invokeMethod(object, "toggle"); + + QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12); + + delete object; + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("conflicting.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6); + + QMetaObject::invokeMethod(object, "toggle"); + + QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12); + + QMetaObject::invokeMethod(object, "toggle"); + + QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6); + + delete object; + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("conflicting.3.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12); + + QMetaObject::invokeMethod(object, "toggle"); + + QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 24); + + QMetaObject::invokeMethod(object, "toggle"); + + QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12); + + delete object; + } +} + QTEST_MAIN(tst_qdeclarativevaluetypes) #include "tst_qdeclarativevaluetypes.moc" diff --git a/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml b/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml index 4d9df43..5f9f757 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml @@ -23,8 +23,8 @@ Grid { newWindowParent: pages url: "newwindows.html" Timer { - interval: 10; running: webView.status==WebView.Ready && total<4; repeat: false; - onTriggered: {total++; webView.evaluateJavaScript("clickTheLink()")} + interval: 10; running: total<4; repeat: false; + onTriggered: { if (webView.status==WebView.Ready) { total++; webView.evaluateJavaScript("clickTheLink()") } } } } } diff --git a/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp b/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp index b63e14b..ce389f3 100644 --- a/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp +++ b/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp @@ -122,8 +122,7 @@ void tst_qdeclarativewebview::cleanupTestCase() void tst_qdeclarativewebview::checkNoErrors(const QDeclarativeComponent& component) { // Wait until the component is ready - QTRY_VERIFY(component.isReady()); - + QTRY_VERIFY(component.isReady() || component.isError()); if (component.isError()) { QList<QDeclarativeError> errors = component.errors(); @@ -313,8 +312,8 @@ void tst_qdeclarativewebview::multipleWindows() QDeclarativeGrid *grid = qobject_cast<QDeclarativeGrid*>(component.create()); QVERIFY(grid != 0); - QTRY_COMPARE(grid->children().count(), 2+5); // Component, Loader, 5 WebViews - QDeclarativeItem* popup = qobject_cast<QDeclarativeItem*>(grid->children().at(3)); // first popup after Component, Loaded, original. + QTRY_COMPARE(grid->children().count(), 2+4); // Component, Loader (with 1 WebView), 4 new-window WebViews + QDeclarativeItem* popup = qobject_cast<QDeclarativeItem*>(grid->children().at(2)); // first popup after Component and Loader. QVERIFY(popup != 0); QTRY_COMPARE(popup->x(), 150.0); } diff --git a/tests/auto/declarative/qdeclarativeworkerlistmodel/data/model.qml b/tests/auto/declarative/qdeclarativeworkerlistmodel/data/model.qml deleted file mode 100644 index be94e00..0000000 --- a/tests/auto/declarative/qdeclarativeworkerlistmodel/data/model.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt 4.6 - -Item { - property alias model: model - - WorkerListModel { id: model } - - function workerModifyModel(cmd) { worker.sendMessage({'command': cmd, 'model': model}) } - - WorkerScript { - id: worker - source: "script.js" - } -} diff --git a/tests/auto/declarative/qdeclarativeworkerlistmodel/data/script.js b/tests/auto/declarative/qdeclarativeworkerlistmodel/data/script.js deleted file mode 100644 index 8ee62b4..0000000 --- a/tests/auto/declarative/qdeclarativeworkerlistmodel/data/script.js +++ /dev/null @@ -1,6 +0,0 @@ -WorkerScript.onMessage = function(msg) { - eval("msg.model." + msg.command) - msg.model.sync() -} - - diff --git a/tests/auto/declarative/qdeclarativeworkerlistmodel/qdeclarativeworkerlistmodel.pro b/tests/auto/declarative/qdeclarativeworkerlistmodel/qdeclarativeworkerlistmodel.pro deleted file mode 100644 index 960dbe1..0000000 --- a/tests/auto/declarative/qdeclarativeworkerlistmodel/qdeclarativeworkerlistmodel.pro +++ /dev/null @@ -1,9 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative -QT += script -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativeworkerlistmodel.cpp - -# Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeworkerlistmodel/tst_qdeclarativeworkerlistmodel.cpp b/tests/auto/declarative/qdeclarativeworkerlistmodel/tst_qdeclarativeworkerlistmodel.cpp deleted file mode 100644 index 11a7447..0000000 --- a/tests/auto/declarative/qdeclarativeworkerlistmodel/tst_qdeclarativeworkerlistmodel.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 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 <qtest.h> -#include <QtCore/qdebug.h> - -#include <QtDeclarative/qdeclarativecomponent.h> -#include <QtDeclarative/qdeclarativeengine.h> -#include <QtDeclarative/qdeclarativeitem.h> - -#include <private/qdeclarativeworkerscript_p.h> -#include <private/qdeclarativelistmodel_p.h> -#include "../../../shared/util.h" - - - -class tst_QDeclarativeWorkerListModel : public QObject -{ - Q_OBJECT -public: - tst_QDeclarativeWorkerListModel() {} -private slots: - void clear(); - void remove(); - void append(); - void insert(); - void get(); - void set(); - -private: - QByteArray modificationWarning() const { - QString file = QUrl::fromLocalFile(SRCDIR "/data/model.qml").toString(); - return QString("QML WorkerListModel (" + file + ":6:5) List can only be modified from a WorkerScript").toUtf8(); - } - - QDeclarativeEngine m_engine; -}; - -void tst_QDeclarativeWorkerListModel::clear() -{ - QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); - QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); - QVERIFY(item != 0); - QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); - QVERIFY(model != 0); - - QCOMPARE(model->count(), 0); - QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "append({'name': 'A'})"))); - QTRY_COMPARE(model->count(), 1); - - QTest::ignoreMessage(QtWarningMsg, modificationWarning().constData()); - model->clear(); - QCOMPARE(model->count(), 1); - - QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "clear()"))); - QTRY_COMPARE(model->count(), 0); - - qApp->processEvents(); -} - -void tst_QDeclarativeWorkerListModel::remove() -{ - QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); - QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); - QVERIFY(item != 0); - QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); - QVERIFY(model != 0); - - QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "append({'name': 'A'})"))); - QTRY_COMPARE(model->count(), 1); - - QTest::ignoreMessage(QtWarningMsg, modificationWarning().constData()); - model->remove(0); - QCOMPARE(model->count(), 1); - - QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "remove(0)"))); - QTRY_COMPARE(model->count(), 0); - - qApp->processEvents(); -} - -void tst_QDeclarativeWorkerListModel::append() -{ - QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); - QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); - QVERIFY(item != 0); - QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); - QVERIFY(model != 0); - - QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "append({'name': 'A'})"))); - QTRY_COMPARE(model->count(), 1); - - QTest::ignoreMessage(QtWarningMsg, modificationWarning().constData()); - model->append(QScriptValue(1)); - QCOMPARE(model->count(), 1); - - qApp->processEvents(); -} - -void tst_QDeclarativeWorkerListModel::insert() -{ - QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); - QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); - QVERIFY(item != 0); - QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); - QVERIFY(model != 0); - - QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "insert(0, {'name': 'A'})"))); - QTRY_COMPARE(model->count(), 1); - - QTest::ignoreMessage(QtWarningMsg, modificationWarning().constData()); - model->insert(0, QScriptValue(1)); - QCOMPARE(model->count(), 1); - - qApp->processEvents(); -} - -void tst_QDeclarativeWorkerListModel::get() -{ - QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); - QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); - QVERIFY(item != 0); - QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); - QVERIFY(model != 0); - - QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "append({'name': 'A'})"))); - QTRY_COMPARE(model->count(), 1); - QCOMPARE(model->get(0).property("name").toString(), QString("A")); - - qApp->processEvents(); -} - -void tst_QDeclarativeWorkerListModel::set() -{ - QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); - QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); - QVERIFY(item != 0); - QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); - QVERIFY(model != 0); - - QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "append({'name': 'A'})"))); - QTRY_COMPARE(model->count(), 1); - - QTest::ignoreMessage(QtWarningMsg, modificationWarning().constData()); - model->set(0, QScriptValue(1)); - - QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "set(0, {'name': 'Z'})"))); - QTRY_COMPARE(model->get(0).property("name").toString(), QString("Z")); - - qApp->processEvents(); -} - -QTEST_MAIN(tst_QDeclarativeWorkerListModel) - -#include "tst_qdeclarativeworkerlistmodel.moc" - diff --git a/tests/auto/declarative/visual/animation/parentAnimation/parentAnimation.qml b/tests/auto/declarative/visual/animation/parentAnimation/parentAnimation.qml index 1833cf0..5db2cc6 100644 --- a/tests/auto/declarative/visual/animation/parentAnimation/parentAnimation.qml +++ b/tests/auto/declarative/visual/animation/parentAnimation/parentAnimation.qml @@ -10,7 +10,7 @@ Rectangle { width: 100; height: 100 } - MouseRegion { + MouseArea { id: mouser anchors.fill: parent } diff --git a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.0.png b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.0.png Binary files differindex c7bbf38..454f6c1 100644 --- a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.0.png +++ b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.0.png diff --git a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.1.png b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.1.png Binary files differindex 612500b..9dde537 100644 --- a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.1.png +++ b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.1.png diff --git a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.2.png b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.2.png Binary files differindex c7bbf38..454f6c1 100644 --- a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.2.png +++ b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.2.png diff --git a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.3.png b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.3.png Binary files differindex c7bbf38..454f6c1 100644 --- a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.3.png +++ b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.3.png diff --git a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.4.png b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.4.png Binary files differindex 1910eb4..043b487 100644 --- a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.4.png +++ b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.4.png diff --git a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.5.png b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.5.png Binary files differindex 3b8eebd..79c791d 100644 --- a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.5.png +++ b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.5.png diff --git a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.6.png b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.6.png Binary files differindex c7bbf38..454f6c1 100644 --- a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.6.png +++ b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.6.png diff --git a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.7.png b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.7.png Binary files differindex c7bbf38..454f6c1 100644 --- a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.7.png +++ b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.7.png diff --git a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.8.png b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.8.png Binary files differindex 960be31..a7d6674 100644 --- a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.8.png +++ b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.8.png diff --git a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.qml b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.qml index 0f58de5..a130b75 100644 --- a/tests/auto/declarative/visual/animation/reanchor/data/reanchor.qml +++ b/tests/auto/declarative/visual/animation/reanchor/data/reanchor.qml @@ -386,115 +386,115 @@ VisualTest { } Frame { msec: 1472 - hash: "c2d6dd91f3e9cdcacbadcb449c8a9896" + hash: "eb3eeb37ab7b26692cbf100adfaf3772" } Frame { msec: 1488 - hash: "1098ea19aecebd71208e101d522c1981" + hash: "e1a8cdcb1f3ec097a968b3b20964c6e8" } Frame { msec: 1504 - hash: "8cc59c20d796c073038518d2855fb6f0" + hash: "44fc52479251327d0612de17ddb056eb" } Frame { msec: 1520 - hash: "914a89d0cfdc68145024ce2305a5e76e" + hash: "fa7e4a910aa60500575a34852c0c7cb8" } Frame { msec: 1536 - hash: "7a2e3ca2660df24d9a6ec49a7422ebe1" + hash: "66d205a02e35221e7684ab995acc1312" } Frame { msec: 1552 - hash: "b71496d986d5f0aa76b4f1663627f1f7" + hash: "4ebe8dba6d9f3179b610b2298a7484a2" } Frame { msec: 1568 - hash: "41b29a523db919bc0a4e0a9a88bfc873" + hash: "9b2582fccffa34fe389ba427ce47619a" } Frame { msec: 1584 - hash: "97632a0de766b9ffbf71f21eeb0ff9a2" + hash: "e6f15478bda9995f82976b9e16659c8e" } Frame { msec: 1600 - hash: "94cc196e62c150008461ff9996b4cae8" + hash: "f08df0885fff04819ada6c10b25dd489" } Frame { msec: 1616 - hash: "32e96ad2d15fa2386d365ab249ddf4f4" + hash: "0f57c152306747cfa27171f1947ca65d" } Frame { msec: 1632 - hash: "209394314f971b12fbc61ca45010cc62" + hash: "89d9c988abd55063e210b81193c6a8f0" } Frame { msec: 1648 - hash: "b917c2684dda8af00278b34ababdcf5c" + hash: "91e0d0a5d57210c790c2d2399d1f7022" } Frame { msec: 1664 - hash: "92b506860c1c5dc52f87c24c89921b05" + hash: "267874fdc09459b3e854c06d9ae99a54" } Frame { msec: 1680 - hash: "7b7e96113fa9359954be9b3ac87943c3" + hash: "2f58a508f439c40c6f2bd7da1f30deff" } Frame { msec: 1696 - hash: "42bc69db42c5df902038cec414246ec5" + hash: "1451548d9f0002a6c4765cb616ab7f59" } Frame { msec: 1712 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 1728 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 1744 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 1760 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 1776 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 1792 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 1808 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 1824 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 1840 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 1856 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 1872 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 1888 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 1904 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 1920 @@ -502,47 +502,47 @@ VisualTest { } Frame { msec: 1936 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 1952 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 1968 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 1984 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 2000 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 2016 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 2032 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 2048 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 2064 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 2080 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 2096 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Mouse { type: 2 @@ -554,31 +554,31 @@ VisualTest { } Frame { msec: 2112 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 2128 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 2144 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 2160 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 2176 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 2192 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 2208 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Mouse { type: 3 @@ -590,67 +590,67 @@ VisualTest { } Frame { msec: 2224 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 2240 - hash: "2d1aa011f2008a6147ba593e3cf272d7" + hash: "8ceca291e28f52368346f171c2f31664" } Frame { msec: 2256 - hash: "206699ea84ce9fd60c1603b7a48a5134" + hash: "903877286f3ef112e6a661abde5c17bd" } Frame { msec: 2272 - hash: "68eb6df93a2b6db7023f7c3cc71d5b5f" + hash: "cc2d15c96571f9328b929f96849c8f9e" } Frame { msec: 2288 - hash: "5a4cd0620959dde92eeeaaa4dcd13091" + hash: "26e6c03b1b91b725d6e0fe9216a7413e" } Frame { msec: 2304 - hash: "17b763187a777253b25b22f5dd7253ae" + hash: "213e8e9905bea32ddb97d38b75cd19cc" } Frame { msec: 2320 - hash: "1de9dcf4d385266f4482e2d0967d9119" + hash: "17d5726a282d42fcde7796be84606fcd" } Frame { msec: 2336 - hash: "833496add6dbc3103a28a47e453a738b" + hash: "f4629bf9f5837f687ae49008c9d28d02" } Frame { msec: 2352 - hash: "b3bab2e9c56db60cd54e68369e6b790d" + hash: "fbc927cb136d8d29b2578e78c4793e41" } Frame { msec: 2368 - hash: "ee91c6cd909bec401a1a7eebd10b8b02" + hash: "c7099e732490dd2f3205986a7c43a165" } Frame { msec: 2384 - hash: "0ed679ad0ab7bd3544947bccda88647b" + hash: "b3b464a8e67fab05109b49604f1ce705" } Frame { msec: 2400 - hash: "d7dfcdc8a4233821919f1732d8c39712" + hash: "7629b2a77f9f87aa0ef2535aa9b8d390" } Frame { msec: 2416 - hash: "c52829ee689e4c312a9dff8dbd4a79f9" + hash: "6a329c289236782e095cfa6f15409726" } Frame { msec: 2432 - hash: "7962badda0e80a61b67943d3b31f892d" + hash: "1cfbf6f4c292e1520b44d84dd59b93a8" } Frame { msec: 2448 - hash: "fc5f2c24e3d8743ab5b20aaa122bacc2" + hash: "a8d3d838bffb39053eb705aefcb39c46" } Frame { msec: 2464 - hash: "201b9ee6c9ac6208ef812fe2e95020ef" + hash: "a56ad66a949e07e3174a58c80145c85e" } Frame { msec: 2480 @@ -774,123 +774,123 @@ VisualTest { } Frame { msec: 2896 - hash: "c2d6dd91f3e9cdcacbadcb449c8a9896" + hash: "eb3eeb37ab7b26692cbf100adfaf3772" } Frame { msec: 2912 - hash: "1098ea19aecebd71208e101d522c1981" + hash: "e1a8cdcb1f3ec097a968b3b20964c6e8" } Frame { msec: 2928 - hash: "8cc59c20d796c073038518d2855fb6f0" + hash: "44fc52479251327d0612de17ddb056eb" } Frame { msec: 2944 - hash: "914a89d0cfdc68145024ce2305a5e76e" + hash: "fa7e4a910aa60500575a34852c0c7cb8" } Frame { msec: 2960 - hash: "7a2e3ca2660df24d9a6ec49a7422ebe1" + hash: "66d205a02e35221e7684ab995acc1312" } Frame { msec: 2976 - hash: "b71496d986d5f0aa76b4f1663627f1f7" + hash: "4ebe8dba6d9f3179b610b2298a7484a2" } Frame { msec: 2992 - hash: "41b29a523db919bc0a4e0a9a88bfc873" + hash: "9b2582fccffa34fe389ba427ce47619a" } Frame { msec: 3008 - hash: "97632a0de766b9ffbf71f21eeb0ff9a2" + hash: "e6f15478bda9995f82976b9e16659c8e" } Frame { msec: 3024 - hash: "94cc196e62c150008461ff9996b4cae8" + hash: "f08df0885fff04819ada6c10b25dd489" } Frame { msec: 3040 - hash: "32e96ad2d15fa2386d365ab249ddf4f4" + hash: "0f57c152306747cfa27171f1947ca65d" } Frame { msec: 3056 - hash: "209394314f971b12fbc61ca45010cc62" + hash: "89d9c988abd55063e210b81193c6a8f0" } Frame { msec: 3072 - hash: "b917c2684dda8af00278b34ababdcf5c" + hash: "91e0d0a5d57210c790c2d2399d1f7022" } Frame { msec: 3088 - hash: "92b506860c1c5dc52f87c24c89921b05" + hash: "267874fdc09459b3e854c06d9ae99a54" } Frame { msec: 3104 - hash: "7b7e96113fa9359954be9b3ac87943c3" + hash: "2f58a508f439c40c6f2bd7da1f30deff" } Frame { msec: 3120 - hash: "42bc69db42c5df902038cec414246ec5" + hash: "1451548d9f0002a6c4765cb616ab7f59" } Frame { msec: 3136 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3152 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3168 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3184 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3200 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3216 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3232 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3248 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3264 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3280 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3296 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3312 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3328 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3344 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3360 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Mouse { type: 2 @@ -902,31 +902,31 @@ VisualTest { } Frame { msec: 3376 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3392 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3408 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3424 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3440 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3456 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3472 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Mouse { type: 3 @@ -938,67 +938,67 @@ VisualTest { } Frame { msec: 3488 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 3504 - hash: "2d1aa011f2008a6147ba593e3cf272d7" + hash: "8ceca291e28f52368346f171c2f31664" } Frame { msec: 3520 - hash: "206699ea84ce9fd60c1603b7a48a5134" + hash: "903877286f3ef112e6a661abde5c17bd" } Frame { msec: 3536 - hash: "68eb6df93a2b6db7023f7c3cc71d5b5f" + hash: "cc2d15c96571f9328b929f96849c8f9e" } Frame { msec: 3552 - hash: "5a4cd0620959dde92eeeaaa4dcd13091" + hash: "26e6c03b1b91b725d6e0fe9216a7413e" } Frame { msec: 3568 - hash: "17b763187a777253b25b22f5dd7253ae" + hash: "213e8e9905bea32ddb97d38b75cd19cc" } Frame { msec: 3584 - hash: "1de9dcf4d385266f4482e2d0967d9119" + hash: "17d5726a282d42fcde7796be84606fcd" } Frame { msec: 3600 - hash: "833496add6dbc3103a28a47e453a738b" + hash: "f4629bf9f5837f687ae49008c9d28d02" } Frame { msec: 3616 - hash: "b3bab2e9c56db60cd54e68369e6b790d" + hash: "fbc927cb136d8d29b2578e78c4793e41" } Frame { msec: 3632 - hash: "ee91c6cd909bec401a1a7eebd10b8b02" + hash: "c7099e732490dd2f3205986a7c43a165" } Frame { msec: 3648 - hash: "0ed679ad0ab7bd3544947bccda88647b" + hash: "b3b464a8e67fab05109b49604f1ce705" } Frame { msec: 3664 - hash: "d7dfcdc8a4233821919f1732d8c39712" + hash: "7629b2a77f9f87aa0ef2535aa9b8d390" } Frame { msec: 3680 - hash: "c52829ee689e4c312a9dff8dbd4a79f9" + hash: "6a329c289236782e095cfa6f15409726" } Frame { msec: 3696 - hash: "7962badda0e80a61b67943d3b31f892d" + hash: "1cfbf6f4c292e1520b44d84dd59b93a8" } Frame { msec: 3712 - hash: "fc5f2c24e3d8743ab5b20aaa122bacc2" + hash: "a8d3d838bffb39053eb705aefcb39c46" } Frame { msec: 3728 - hash: "201b9ee6c9ac6208ef812fe2e95020ef" + hash: "a56ad66a949e07e3174a58c80145c85e" } Frame { msec: 3744 @@ -2038,183 +2038,183 @@ VisualTest { } Frame { msec: 7696 - hash: "c2d6dd91f3e9cdcacbadcb449c8a9896" + hash: "eb3eeb37ab7b26692cbf100adfaf3772" } Frame { msec: 7712 - hash: "1098ea19aecebd71208e101d522c1981" + hash: "e1a8cdcb1f3ec097a968b3b20964c6e8" } Frame { msec: 7728 - hash: "8cc59c20d796c073038518d2855fb6f0" + hash: "44fc52479251327d0612de17ddb056eb" } Frame { msec: 7744 - hash: "914a89d0cfdc68145024ce2305a5e76e" + hash: "fa7e4a910aa60500575a34852c0c7cb8" } Frame { msec: 7760 - hash: "7a2e3ca2660df24d9a6ec49a7422ebe1" + hash: "66d205a02e35221e7684ab995acc1312" } Frame { msec: 7776 - hash: "b71496d986d5f0aa76b4f1663627f1f7" + hash: "4ebe8dba6d9f3179b610b2298a7484a2" } Frame { msec: 7792 - hash: "41b29a523db919bc0a4e0a9a88bfc873" + hash: "9b2582fccffa34fe389ba427ce47619a" } Frame { msec: 7808 - hash: "97632a0de766b9ffbf71f21eeb0ff9a2" + hash: "e6f15478bda9995f82976b9e16659c8e" } Frame { msec: 7824 - hash: "94cc196e62c150008461ff9996b4cae8" + hash: "f08df0885fff04819ada6c10b25dd489" } Frame { msec: 7840 - hash: "32e96ad2d15fa2386d365ab249ddf4f4" + hash: "0f57c152306747cfa27171f1947ca65d" } Frame { msec: 7856 - hash: "209394314f971b12fbc61ca45010cc62" + hash: "89d9c988abd55063e210b81193c6a8f0" } Frame { msec: 7872 - hash: "b917c2684dda8af00278b34ababdcf5c" + hash: "91e0d0a5d57210c790c2d2399d1f7022" } Frame { msec: 7888 - hash: "92b506860c1c5dc52f87c24c89921b05" + hash: "267874fdc09459b3e854c06d9ae99a54" } Frame { msec: 7904 - hash: "7b7e96113fa9359954be9b3ac87943c3" + hash: "2f58a508f439c40c6f2bd7da1f30deff" } Frame { msec: 7920 - hash: "42bc69db42c5df902038cec414246ec5" + hash: "1451548d9f0002a6c4765cb616ab7f59" } Frame { msec: 7936 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 7952 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 7968 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 7984 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8000 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8016 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8032 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8048 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8064 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8080 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8096 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8112 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8128 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8144 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8160 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8176 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8192 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8208 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8224 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8240 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8256 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8272 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8288 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8304 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8320 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8336 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8352 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8368 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8384 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8400 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Mouse { type: 2 @@ -2226,31 +2226,31 @@ VisualTest { } Frame { msec: 8416 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8432 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8448 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8464 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8480 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8496 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8512 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Mouse { type: 3 @@ -2262,31 +2262,31 @@ VisualTest { } Frame { msec: 8528 - hash: "7eb4027421fd6aa7d668a704e40a6e61" + hash: "ad3837dcf3e69274ac2918d796974f29" } Frame { msec: 8544 - hash: "b4f30663a9b21e42375645e970f57d0b" + hash: "49a6ed64f80094b41348eda19fa5a55e" } Frame { msec: 8560 - hash: "6c12dbf4af8801573515b61123d4b1d7" + hash: "3ee42fb431d7824c1cd6ddf95af91d10" } Frame { msec: 8576 - hash: "facc61397c734bb4409d5664dc059a14" + hash: "d807890cc0670eda9fac267769366771" } Frame { msec: 8592 - hash: "897e15e37276454d11fac6a528e967a6" + hash: "50cb68de9ca0c3a8db1df58d7cbb0d21" } Frame { msec: 8608 - hash: "cf8173519f1e042c227ff61c62308640" + hash: "0af06233156b3a469ce9e7d80a5767c0" } Frame { msec: 8624 - hash: "d0fcda14ea4bcfebf04ccf99e292ac6a" + hash: "9b2c77f004e480fd485e092c08feaf81" } Frame { msec: 8640 @@ -2294,35 +2294,35 @@ VisualTest { } Frame { msec: 8656 - hash: "74b4ababa97def538f5340e88a4419a4" + hash: "6ed9b6118a0dc81c22af9fee108b7432" } Frame { msec: 8672 - hash: "b96b5b64505b1814ddd42a52569d7fd9" + hash: "4d3aa8219edffe6fda316482821d4a64" } Frame { msec: 8688 - hash: "0e3e07aad030b2075c4bc61b02ebe49e" + hash: "ea8a7104840254ac2706ca2635b8a95f" } Frame { msec: 8704 - hash: "c5eebc652c58e3a44d5ed481100ef242" + hash: "a8569ef3287da9699809a2ad107b87b1" } Frame { msec: 8720 - hash: "d4a74185304c126739af728ddda40e0c" + hash: "91d09653dbced4ecb3d711737cb89ca1" } Frame { msec: 8736 - hash: "448572d3c1060b8311952429a7f9430d" + hash: "d5391f3b40f2dfada0336d889d438d69" } Frame { msec: 8752 - hash: "00f64c09657a8afd6caa186efb6ad860" + hash: "27cd9690607f97cc84c2a0a4455feccb" } Frame { msec: 8768 - hash: "2a360e6feaaf303e9ee63145085796e6" + hash: "f885588779a5de5d7d47f48bf9a2a6ee" } Frame { msec: 8784 @@ -2419,7 +2419,7 @@ VisualTest { Key { type: 6 key: 16777249 - modifiers: 67108864 + modifiers: 0 text: "" autorep: false count: 1 diff --git a/tests/auto/declarative/visual/animation/reanchor/reanchor.qml b/tests/auto/declarative/visual/animation/reanchor/reanchor.qml index d80631f..e41a254 100644 --- a/tests/auto/declarative/visual/animation/reanchor/reanchor.qml +++ b/tests/auto/declarative/visual/animation/reanchor/reanchor.qml @@ -52,7 +52,7 @@ Rectangle { }] transitions: Transition { - NumberAnimation { properties: "x,y,width,height" } + AnchorAnimation { } } MouseArea { diff --git a/tests/auto/maketestselftest/features/dump_subdirs.prf b/tests/auto/maketestselftest/features/dump_subdirs.prf new file mode 100644 index 0000000..2547f58 --- /dev/null +++ b/tests/auto/maketestselftest/features/dump_subdirs.prf @@ -0,0 +1,4 @@ +for(dir, SUBDIRS) { + message(subdir: $$dir) +} + diff --git a/tests/auto/maketestselftest/tst_maketestselftest.cpp b/tests/auto/maketestselftest/tst_maketestselftest.cpp index 8264e27..437e143 100644 --- a/tests/auto/maketestselftest/tst_maketestselftest.cpp +++ b/tests/auto/maketestselftest/tst_maketestselftest.cpp @@ -44,16 +44,62 @@ #include <QRegExp> #include <QStringList> #include <QTest> +#include <QSet> +#include <QProcess> +#include <QDebug> + +enum FindSubdirsMode { + Flat = 0, + Recursive +}; class tst_MakeTestSelfTest: public QObject { Q_OBJECT private slots: + void tests_auto_pro(); + void tests_pro_files(); void tests_pro_files_data(); + + void naming_convention(); + void naming_convention_data(); + +private: + QStringList find_subdirs(QString const&, FindSubdirsMode, QString const& = QString()); + + QSet<QString> all_test_classes; }; +bool looks_like_testcase(QString const&,QString*); +bool looks_like_subdirs(QString const&); +QStringList find_test_class(QString const&); + +/* + Verify that auto.pro only contains other .pro files (and not directories). + We enforce this so that we can process every .pro file other than auto.pro + independently and get all the tests. + If tests were allowed to appear directly in auto.pro, we'd have the problem + that we need to somehow run these tests from auto.pro while preventing + recursion into the other .pro files. +*/ +void tst_MakeTestSelfTest::tests_auto_pro() +{ + QStringList subdirsList = find_subdirs(SRCDIR "/../auto.pro", Flat); + if (QTest::currentTestFailed()) { + return; + } + + foreach (QString const& subdir, subdirsList) { + QVERIFY2(subdir.endsWith(".pro"), qPrintable(QString( + "auto.pro contains a subdir `%1'.\n" + "auto.pro must _only_ contain other .pro files, not actual subdirs.\n" + "Please move `%1' into some other .pro file referenced by auto.pro." + ).arg(subdir))); + } +} + /* Verify that all tests are listed somewhere in one of the autotest .pro files */ void tst_MakeTestSelfTest::tests_pro_files() { @@ -82,6 +128,8 @@ void tst_MakeTestSelfTest::tests_pro_files() } } + + QFAIL(qPrintable(QString( "Subdir `%1' is missing from tests/auto/*.pro\n" "This means the test won't be compiled or run on any platform.\n" @@ -106,5 +154,355 @@ void tst_MakeTestSelfTest::tests_pro_files_data() } } +QString format_list(QStringList const& list) +{ + if (list.count() == 1) { + return list.at(0); + } + return QString("one of (%1)").arg(list.join(", ")); +} + +void tst_MakeTestSelfTest::naming_convention() +{ + QFETCH(QString, subdir); + QFETCH(QString, target); + + QDir dir(SRCDIR "/../" + subdir); + + QStringList cppfiles = dir.entryList(QStringList() << "*.h" << "*.cpp"); + if (cppfiles.isEmpty()) { + // Common convention is to have test/test.pro and source files in parent dir + if (dir.dirName() == "test") { + dir.cdUp(); + cppfiles = dir.entryList(QStringList() << "*.h" << "*.cpp"); + } + + if (cppfiles.isEmpty()) { + QSKIP("Couldn't locate source files for test", SkipSingle); + } + } + + QStringList possible_test_classes; + foreach (QString const& file, cppfiles) { + possible_test_classes << find_test_class(dir.path() + "/" + file); + } + + if (possible_test_classes.isEmpty()) { + QSKIP(qPrintable(QString("Couldn't locate test class in %1").arg(format_list(cppfiles))), SkipSingle); + } + + QVERIFY2(possible_test_classes.contains(target), qPrintable(QString( + "TARGET is %1, while test class appears to be %2.\n" + "TARGET and test class _must_ match so that all testcase names can be accurately " + "determined even if a test fails to compile or run.") + .arg(target) + .arg(format_list(possible_test_classes)) + )); + + QVERIFY2(!all_test_classes.contains(target), qPrintable(QString( + "It looks like there are multiple tests named %1.\n" + "This makes it impossible to separate results for these tests.\n" + "Please ensure all tests are uniquely named.") + .arg(target) + )); + + all_test_classes << target; +} + +void tst_MakeTestSelfTest::naming_convention_data() +{ + QTest::addColumn<QString>("subdir"); + QTest::addColumn<QString>("target"); + + foreach (const QString& subdir, find_subdirs(SRCDIR "/../auto.pro", Recursive)) { + if (QFileInfo(SRCDIR "/../" + subdir).isDir()) { + QString target; + if (looks_like_testcase(SRCDIR "/../" + subdir + "/" + QFileInfo(subdir).baseName() + ".pro", &target)) { + QTest::newRow(qPrintable(subdir)) << subdir << target.toLower(); + } + } + } +} + +/* + Returns true if a .pro file seems to be for an autotest. + Running qmake to figure this out takes too long. +*/ +bool looks_like_testcase(QString const& pro_file, QString* target) +{ + QFile file(pro_file); + if (!file.open(QIODevice::ReadOnly)) { + return false; + } + + *target = QString(); + + bool loaded_qttest = false; + + do { + QByteArray line = file.readLine(); + if (line.isEmpty()) { + break; + } + + line = line.trimmed(); + line.replace(' ', ""); + + if (line == "load(qttest_p4)") { + loaded_qttest = true; + } + + if (line.startsWith("TARGET=")) { + *target = QString::fromLatin1(line.mid(sizeof("TARGET=")-1)); + if (target->contains('/')) { + *target = target->right(target->lastIndexOf('/')+1); + } + } + + if (loaded_qttest && !target->isEmpty()) { + break; + } + } while(1); + + if (!loaded_qttest) { + return false; + } + + if (!target->isEmpty() && !target->startsWith("tst_")) { + return false; + } + + // If no target was set, default to tst_<dirname> + if (target->isEmpty()) { + *target = "tst_" + QFileInfo(pro_file).baseName(); + } + + return true; +} + +/* + Returns true if a .pro file seems to be a subdirs project. + Running qmake to figure this out takes too long. +*/ +bool looks_like_subdirs(QString const& pro_file) +{ + QFile file(pro_file); + if (!file.open(QIODevice::ReadOnly)) { + return false; + } + + do { + QByteArray line = file.readLine(); + if (line.isEmpty()) { + break; + } + + line = line.trimmed(); + line.replace(' ', ""); + + if (line == "TEMPLATE=subdirs") { + return true; + } + } while(1); + + return false; +} + +/* + Returns a list of all subdirs in a given .pro file +*/ +QStringList tst_MakeTestSelfTest::find_subdirs(QString const& pro_file, FindSubdirsMode mode, QString const& prefix) +{ + QStringList out; + + QByteArray features = qgetenv("QMAKEFEATURES"); + + if (features.isEmpty()) { + features = SRCDIR "/features"; + } + else { + features.prepend(SRCDIR "/features" +#ifdef Q_OS_WIN32 + ";" +#else + ":" +#endif + ); + } + + QStringList args; + args << pro_file << "-o" << SRCDIR "/dummy_output" << "CONFIG+=dump_subdirs"; + + /* Turn on every option there is, to ensure we process every single directory */ + args + << "QT_CONFIG+=dbus" + << "QT_CONFIG+=declarative" + << "QT_CONFIG+=egl" + << "QT_CONFIG+=multimedia" + << "QT_CONFIG+=OdfWriter" + << "QT_CONFIG+=opengl" + << "QT_CONFIG+=openvg" + << "QT_CONFIG+=phonon" + << "QT_CONFIG+=private_tests" + << "QT_CONFIG+=pulseaudio" + << "QT_CONFIG+=qt3support" + << "QT_CONFIG+=script" + << "QT_CONFIG+=svg" + << "QT_CONFIG+=webkit" + << "QT_CONFIG+=xmlpatterns" + << "CONFIG+=mac" + << "CONFIG+=embedded" + << "CONFIG+=symbian" + ; + + + + QString cmd_with_args = QString("qmake %1").arg(args.join(" ")); + + QProcess proc; + + proc.setProcessChannelMode(QProcess::MergedChannels); + + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + env.insert("QMAKEFEATURES", features); + proc.setProcessEnvironment(env); + + proc.start("qmake", args); + if (!proc.waitForStarted(10000)) { + QTest::qFail(qPrintable(QString("Failed to run qmake: %1\nCommand: %2") + .arg(proc.errorString()) + .arg(cmd_with_args)), + __FILE__, __LINE__ + ); + return out; + } + if (!proc.waitForFinished(30000)) { + QTest::qFail(qPrintable(QString("qmake did not finish within 30 seconds\nCommand: %1\nOutput: %2") + .arg(proc.errorString()) + .arg(cmd_with_args) + .arg(QString::fromLocal8Bit(proc.readAll()))), + __FILE__, __LINE__ + ); + return out; + } + + if (proc.exitStatus() != QProcess::NormalExit) { + QTest::qFail(qPrintable(QString("qmake crashed\nCommand: %1\nOutput: %2") + .arg(cmd_with_args) + .arg(QString::fromLocal8Bit(proc.readAll()))), + __FILE__, __LINE__ + ); + return out; + } + + if (proc.exitCode() != 0) { + QTest::qFail(qPrintable(QString("qmake exited with code %1\nCommand: %2\nOutput: %3") + .arg(proc.exitCode()) + .arg(cmd_with_args) + .arg(QString::fromLocal8Bit(proc.readAll()))), + __FILE__, __LINE__ + ); + return out; + } + + QList<QByteArray> lines = proc.readAll().split('\n'); + if (!lines.count()) { + QTest::qFail(qPrintable(QString("qmake seems to have not output anything\nCommand: %1\n") + .arg(cmd_with_args)), + __FILE__, __LINE__ + ); + return out; + } + + foreach (QByteArray const& line, lines) { + static const QByteArray marker = "Project MESSAGE: subdir: "; + if (line.startsWith(marker)) { + QString subdir = QString::fromLocal8Bit(line.mid(marker.size()).trimmed()); + out << prefix + subdir; + + if (mode == Flat) { + continue; + } + + // Need full path to subdir + QString subdir_filepath = subdir; + subdir_filepath.prepend(QFileInfo(pro_file).path() + "/"); + + // Add subdirs recursively + if (subdir.endsWith(".pro") && looks_like_subdirs(subdir_filepath)) { + // Need full path to .pro file + out << find_subdirs(subdir_filepath, mode, prefix); + } + + if (QFileInfo(subdir_filepath).isDir()) { + subdir_filepath += "/" + subdir + ".pro"; + if (looks_like_subdirs(subdir_filepath)) { + out << find_subdirs(subdir_filepath, mode, prefix + subdir + "/"); + } + } + } + } + + return out; +} + +QStringList find_test_class(QString const& filename) +{ + QStringList out; + + QFile file(filename); + if (!file.open(QIODevice::ReadOnly)) { + return out; + } + + static char const* klass_indicators[] = { + "QTEST_MAIN(", + "QTEST_APPLESS_MAIN(", + "class", + "staticconstcharklass[]=\"", /* hax0r tests which define their own metaobject */ + 0 + }; + + do { + QByteArray line = file.readLine(); + if (line.isEmpty()) { + break; + } + + line = line.trimmed(); + line.replace(' ', ""); + + for (int i = 0; klass_indicators[i]; ++i) { + char const* prefix = klass_indicators[i]; + if (!line.startsWith(prefix)) { + continue; + } + QByteArray klass = line.mid(strlen(prefix)); + if (!klass.startsWith("tst_")) { + continue; + } + for (int j = 0; j < klass.size(); ++j) { + char c = klass[j]; + if (c == '_' + || (c >= '0' && c <= '9') + || (c >= 'A' && c <= 'Z') + || (c >= 'a' && c <= 'z')) { + continue; + } + else { + klass.truncate(j); + break; + } + } + QString klass_str = QString::fromLocal8Bit(klass).toLower(); + if (!out.contains(klass_str)) + out << klass_str; + break; + } + } while(1); + + return out; +} + QTEST_MAIN(tst_MakeTestSelfTest) #include "tst_maketestselftest.moc" diff --git a/tests/auto/mediaobject/media/test.sdp b/tests/auto/mediaobject/media/test.sdp new file mode 100644 index 0000000..0d8706c --- /dev/null +++ b/tests/auto/mediaobject/media/test.sdp @@ -0,0 +1,32 @@ +v=0 +o=- 3476526279 2351211129 IN IP4 XXX.XXX.XXX.XXX +s=SOME STRING +e=support@localhost +c=IN IP4 XXX.XXX.XXX.XXX +t=0 0 +a=range:npt=now- +a=random_access_denied +a=control:rtsp://link +m=video 0 RTP/AVP 96 +b=AS:100 +b=RR:2500 +b=RS:2500 +a=control:rtsp://link +a=rtpmap:96 MP4V-ES/90000 +a=3GPP-Adaptation-Support:1 +a=cliprect:0,0,144,176 +a=mpeg4-esid:201 +a=x-envivio-verid:00022B15 +a=fmtp:96 profile-level-id=2;config=000001b002000001b50ea020202f000001000000012000c788ba9850584121463f +a=framerate:15.0 +m=audio 0 RTP/AVP 97 +b=AS:14 +b=RR:350 +b=RS:350 +a=control:rtsp://link +a=rtpmap:97 AMR/8000 +a=3GPP-Adaptation-Support:1 +a=mpeg4-esid:101 +a=x-envivio-verid:00022B15 +a=fmtp:97 octet-align=1 +a=maxptime:200 diff --git a/tests/auto/mediaobject/mediaobject.pro b/tests/auto/mediaobject/mediaobject.pro index 5d4a098..bef2fe9 100755 --- a/tests/auto/mediaobject/mediaobject.pro +++ b/tests/auto/mediaobject/mediaobject.pro @@ -14,3 +14,9 @@ wince*{ DEFINES += tst_MediaObject=tst_MediaObject_waveout } +symbian*:{ + addFiles.sources = media/test.sdp + addFiles.path = media + DEPLOYMENT += addFiles +} + diff --git a/tests/auto/mediaobject/mediaobject.qrc b/tests/auto/mediaobject/mediaobject.qrc index 4f46213..77954f4 100644 --- a/tests/auto/mediaobject/mediaobject.qrc +++ b/tests/auto/mediaobject/mediaobject.qrc @@ -3,5 +3,6 @@ <file>media/sax.wav</file> <file>media/sax.ogg</file> <file>media/sax.mp3</file> +<file>media/test.sdp</file> </qresource> </RCC> diff --git a/tests/auto/mediaobject/tst_mediaobject.cpp b/tests/auto/mediaobject/tst_mediaobject.cpp index 5ae80b9..5b0943e 100644 --- a/tests/auto/mediaobject/tst_mediaobject.cpp +++ b/tests/auto/mediaobject/tst_mediaobject.cpp @@ -139,6 +139,7 @@ class tst_MediaObject : public QObject void pauseToPause(); void pauseToPlay(); void pauseToStop(); + void playSDP(); void testPrefinishMark(); void testSeek(); @@ -160,6 +161,11 @@ class tst_MediaObject : public QObject Phonon::MediaObject *m_media; QSignalSpy *m_stateChangedSignalSpy; QString m_tmpFileName; + + static void copyMediaFile(const QString &original, + const QString &name, + QString &resultFilePath, + QUrl *const asURL = 0); #endif //QT_NO_PHONON bool m_success; }; @@ -352,6 +358,24 @@ void tst_MediaObject::_pausePlayback() m_success = true; } +/*! + Copies the file \a name to the testing area. The resulting file name path is + returned in resultFilePath, and also set as a URL in \a asURL. + */ +void tst_MediaObject::copyMediaFile(const QString &original, + const QString &name, + QString &resultFilePath, + QUrl *const asURL) +{ + resultFilePath = QDir::toNativeSeparators(QDir::tempPath() + name); + if (asURL) + *asURL = QUrl::fromLocalFile(resultFilePath); + + QFile::remove(resultFilePath); + QVERIFY(QFile::copy(original, resultFilePath)); + QFile::setPermissions(resultFilePath, QFile::permissions(resultFilePath) | QFile::WriteOther); +} + void tst_MediaObject::initTestCase() { QCoreApplication::setApplicationName("tst_MediaObject"); @@ -375,14 +399,8 @@ void tst_MediaObject::initTestCase() QVERIFY(m_stateChangedSignalSpy->isValid()); m_stateChangedSignalSpy->clear(); - if (m_url.isEmpty()) { - m_tmpFileName = QDir::toNativeSeparators(QDir::tempPath() + MEDIA_FILE); - QFile::remove(m_tmpFileName); - QVERIFY(QFile::copy(MEDIA_FILEPATH, m_tmpFileName)); - QFile::Permissions p = QFile::permissions(m_tmpFileName); - QFile::setPermissions(m_tmpFileName, p | QFile::WriteOther); - m_url = QUrl::fromLocalFile(m_tmpFileName); - } + if (m_url.isEmpty()) + copyMediaFile(MEDIA_FILEPATH, MEDIA_FILE, m_tmpFileName, &m_url); qDebug() << "Using url:" << m_url.toString(); @@ -533,6 +551,47 @@ void tst_MediaObject::pauseToStop() stopPlayback(Phonon::PausedState); } +/*! + + We attempt to play a SDP file. An SDP file essentially describes different + media streams and is hence a layer in front of the actual media(s). + Sometimes the backend handles the SDP file, in other cases not. + + Some Phonon backends doesn't support SDP at all, ifdef appropriately. Real + Player and Helix, the two backends for Symbian, are known to support SDP. + */ +void tst_MediaObject::playSDP() +{ +#ifdef Q_OS_SYMBIAN + QString sdpFile; + copyMediaFile(QLatin1String(":/media/test.sdp"), QLatin1String("test.sdp"), sdpFile); + + // Let's verify our test setup. + QVERIFY(QFileInfo(sdpFile).isReadable()); + + // We need a window in order to setup the video. + QWidget widget; + widget.show(); + + const MediaSource oldSource(m_media->currentSource()); + const MediaSource sdpSource(sdpFile); + m_media->setCurrentSource(sdpSource); + if (m_media->state() != Phonon::StoppedState) + QTest::waitForSignal(m_media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), 10000); + + // At this point we're in error state due to absent media, but it has now loaded the SDP: + QCOMPARE(m_media->errorString(), QString::fromLatin1("Buffering clip failed: Unknown error (-39)")); + + // We cannot play the SDP, we can neither attempt to play it, because we + // won't get a state change from ErrorState to ErrorState, and hence block + // on a never occuring signal. + m_media->setCurrentSource(oldSource); + +#else + QSKIP("Unsupported on this platform.", SkipAll); +#endif +} + void tst_MediaObject::testPrefinishMark() { const qint32 requestedPrefinishMarkTime = 2000; diff --git a/tests/auto/network.pro b/tests/auto/network.pro index 6b24850..dbefa91 100644 --- a/tests/auto/network.pro +++ b/tests/auto/network.pro @@ -17,8 +17,8 @@ SUBDIRS=\ qhttpsocketengine \ qnativesocketengine \ qnetworkaddressentry \ - qnetworkconfigmanager \ qnetworkconfiguration \ + qnetworkconfigurationmanager \ qnetworkcookie \ qnetworkcookiejar \ qnetworkinterface \ diff --git a/tests/auto/opengl.pro b/tests/auto/opengl.pro index 7220c45..9b59cd1 100644 --- a/tests/auto/opengl.pro +++ b/tests/auto/opengl.pro @@ -1,6 +1,6 @@ TEMPLATE=subdirs SUBDIRS=\ qgl \ - qgl_threads \ + qglthreads \ qglbuffer \ diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp index 874eb7b..f837564 100644 --- a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp +++ b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp @@ -48,6 +48,7 @@ #include "../qsqldatabase/tst_databases.h" +const QString qtest(qTableName( "qtest", __FILE__ )); //TESTED_FILES= @@ -142,26 +143,26 @@ void tst_Q3SqlCursor::createTestTables( QSqlDatabase db ) // please never ever change this table; otherwise fix all tests ;) if ( tst_Databases::isMSAccess( db ) ) { - QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest" ) + " ( id int not null, t_varchar varchar(40) not null," + QVERIFY_SQL(q, exec( "create table " + qtest + " ( id int not null, t_varchar varchar(40) not null," "t_char char(40), t_numeric number, primary key (id, t_varchar) )" )); } else { - QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest" ) + " ( id int not null, t_varchar varchar(40) not null," + QVERIFY_SQL(q, exec( "create table " + qtest + " ( id int not null, t_varchar varchar(40) not null," "t_char char(40), t_numeric numeric(6, 3), primary key (id, t_varchar) )" )); } if ( tst_Databases::isSqlServer( db ) ) { //workaround for SQL SERVER since he can store unicode only in nvarchar fields - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode") + " (id int not null, " + QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode", __FILE__) + " (id int not null, " "t_varchar nvarchar(80) not null, t_char nchar(80) )" )); } else { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode") + " (id int not null, " + QVERIFY_SQL(q, exec("create table " + qTableName("qtest_unicode", __FILE__) + " (id int not null, " "t_varchar varchar(100) not null," "t_char char(100))" )); } if (tst_Databases::isMSAccess(db)) { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_precision") + " (col1 number)")); + QVERIFY_SQL(q, exec("create table " + qTableName("qtest_precision", __FILE__) + " (col1 number)")); } else { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_precision") + " (col1 numeric(15, 14))")); + QVERIFY_SQL(q, exec("create table " + qTableName("qtest_precision", __FILE__) + " (col1 numeric(15, 14))")); } } @@ -170,12 +171,12 @@ void tst_Q3SqlCursor::dropTestTables( QSqlDatabase db ) if ( !db.isValid() ) return; QStringList tableNames; - tableNames << qTableName( "qtest" ) - << qTableName( "qtest_unicode" ) - << qTableName( "qtest_precision" ) - << qTableName( "qtest_ovchar" ) - << qTableName( "qtest_onvchar" ) - << qTableName( "qtestPK" ); + tableNames << qtest + << qTableName( "qtest_unicode", __FILE__ ) + << qTableName( "qtest_precision", __FILE__ ) + << qTableName( "qtest_ovchar", __FILE__ ) + << qTableName( "qtest_onvchar", __FILE__ ) + << qTableName( "qtestPK", __FILE__ ); tst_Databases::safeDropTables( db, tableNames ); } @@ -185,8 +186,8 @@ void tst_Q3SqlCursor::populateTestTables( QSqlDatabase db ) return; QSqlQuery q( db ); - q.exec( "delete from " + qTableName( "qtest" ) ); //not fatal - QVERIFY_SQL(q, prepare("insert into " + qTableName( "qtest" ) + " (id, t_varchar, t_char, t_numeric) values (?, ?, ?, ?)")); + q.exec( "delete from " + qtest ); //not fatal + QVERIFY_SQL(q, prepare("insert into " + qtest + " (id, t_varchar, t_char, t_numeric) values (?, ?, ?, ?)")); q.addBindValue(QVariantList() << 0 << 1 << 2 << 3); q.addBindValue(QVariantList() << "VarChar0" << "VarChar1" << "VarChar2" << "VarChar3"); q.addBindValue(QVariantList() << "Char0" << "Char1" << "Char2" << "Char3"); @@ -243,7 +244,7 @@ void tst_Q3SqlCursor::copyConstructor() Q3SqlCursor cur2; { - Q3SqlCursor cur( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur( qtest, true, db ); QVERIFY_SQL(cur, select( cur.index( QString("id") ) )); cur2 = Q3SqlCursor( cur ); // let "cur" run out of scope... @@ -266,7 +267,7 @@ void tst_Q3SqlCursor::value() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlCursor cur( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur( qtest, true, db ); QVERIFY_SQL(cur, select( cur.index( QString("id") ) )); int i = 0; while ( cur.next() ) { @@ -281,7 +282,7 @@ void tst_Q3SqlCursor::primaryIndex() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlCursor cur( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur( qtest, true, db ); QSqlIndex index = cur.primaryIndex(); if ( tst_Databases::isMSAccess( db ) ) { QCOMPARE( index.fieldName(1).upper(), QString( "ID" ) ); @@ -300,7 +301,7 @@ void tst_Q3SqlCursor::insert() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlCursor cur( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur( qtest, true, db ); QSqlRecord* irec = cur.primeInsert(); QVERIFY( irec != 0 ); @@ -338,7 +339,7 @@ void tst_Q3SqlCursor::insertSpecial() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlCursor cur( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur( qtest, true, db ); QSqlRecord* irec = cur.primeInsert(); QVERIFY( irec != 0 ); @@ -386,9 +387,9 @@ void tst_Q3SqlCursor::batchInsert() CHECK_DATABASE( db ); QSqlQuery q( db ); - q.exec( "delete from " + qTableName( "qtest" ) ); + q.exec( "delete from " + qtest ); - Q3SqlCursor cur( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur( qtest, true, db ); int i = 0; for ( ; i < 100; ++i ) { @@ -420,7 +421,7 @@ void tst_Q3SqlCursor::batchInsert() } i = 0; - QVERIFY_SQL(q, exec( "select * from " + qTableName( "qtest" ) + " order by id" )); + QVERIFY_SQL(q, exec( "select * from " + qtest + " order by id" )); while ( q.next() ) { QCOMPARE( q.value( 0 ).toInt(), i ); i++; @@ -452,11 +453,11 @@ void tst_Q3SqlCursor::insertORA() /****** CHARSET TEST ******/ QSqlQuery q( db ); - QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest_ovchar" ) + " ( id int primary key, t_char varchar(40) )" )); + QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest_ovchar", __FILE__ ) + " ( id int primary key, t_char varchar(40) )" )); static const QString val1( "blah1" ); - Q3SqlCursor cur ( qTableName( "qtest_ovchar" ), true, db ); + Q3SqlCursor cur ( qTableName( "qtest_ovchar", __FILE__ ), true, db ); QSqlRecord* irec = cur.primeInsert(); irec->setValue( "id", 1 ); irec->setValue( "t_char", val1 ); @@ -486,9 +487,9 @@ void tst_Q3SqlCursor::insertORA() /****** NCHARSET TEST ********/ - QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest_onvchar" ) + " ( id int primary key, t_nchar nvarchar2(40) )" )); + QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest_onvchar", __FILE__ ) + " ( id int primary key, t_nchar nvarchar2(40) )" )); - Q3SqlCursor cur2 ( qTableName( "qtest_onvchar" ), true, db ); + Q3SqlCursor cur2 ( qTableName( "qtest_onvchar", __FILE__ ), true, db ); irec = cur2.primeInsert(); irec->setValue( "id", 1 ); irec->setValue( "t_nchar", val1 ); @@ -529,7 +530,7 @@ void tst_Q3SqlCursor::unicode() if(db.driverName().startsWith("QIBASE") && (db.databaseName() == "silence.nokia.troll.no:c:\\ibase\\testdb_ascii" || db.databaseName() == "/opt/interbase/qttest.gdb")) QSKIP("Can't transliterate extended unicode to ascii", SkipSingle); - Q3SqlCursor cur( qTableName( "qtest_unicode" ), true, db ); + Q3SqlCursor cur( qTableName( "qtest_unicode", __FILE__ ), true, db ); QSqlRecord* irec = cur.primeInsert(); irec->setValue( 0, 500 ); irec->setValue( 1, utf8str ); @@ -566,7 +567,7 @@ void tst_Q3SqlCursor::precision() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlCursor cur( qTableName( "qtest_precision" ), true, db ); + Q3SqlCursor cur( qTableName( "qtest_precision", __FILE__ ), true, db ); cur.setTrimmed( "col1", true ); QSqlRecord* irec = cur.primeInsert(); irec->setValue( 0, precStr ); @@ -589,7 +590,7 @@ void tst_Q3SqlCursor::setFilter() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlCursor cur( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur( qtest, true, db ); cur.setFilter( "id = 2" ); QVERIFY_SQL(cur, select()); @@ -619,23 +620,23 @@ void tst_Q3SqlCursor::select() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlCursor cur( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur( qtest, true, db ); QVERIFY_SQL(cur, select()); QVERIFY( cur.next() ); QVERIFY( cur.next() ); - Q3SqlCursor cur2( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur2( qtest, true, db ); QVERIFY_SQL(cur2, select( "id = 1" )); QVERIFY( cur2.next() ); QCOMPARE( cur2.value( 0 ).toInt(), 1 ); - Q3SqlCursor cur3( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur3( qtest, true, db ); QVERIFY_SQL(cur3, select( cur3.primaryIndex( false ) )); QVERIFY( cur3.next() ); QVERIFY( cur3.next() ); QCOMPARE( cur3.value( 0 ).toInt(), 1 ); - Q3SqlCursor cur4( qTableName( "qtest" ), true, db ); + Q3SqlCursor cur4( qtest, true, db ); QSqlIndex idx = cur4.primaryIndex( false ); QCOMPARE( (int)idx.count(), 2 ); if ( tst_Databases::isMSAccess( db ) ) { @@ -667,17 +668,17 @@ void tst_Q3SqlCursor::setName() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlCursor c2( qTableName( "qtest" ), true, db ); - QCOMPARE( c2.name(), qTableName( "qtest" ) ); + Q3SqlCursor c2( qtest, true, db ); + QCOMPARE( c2.name(), qtest ); QCOMPARE( c2.fieldName( 0 ).lower(), QString( "id" ) ); Q3SqlCursor c( QString(), true, db ); - c.setName( qTableName( "qtest" ) ); - QCOMPARE( c.name(), qTableName( "qtest" ) ); + c.setName( qtest ); + QCOMPARE( c.name(), qtest ); QCOMPARE( c.fieldName( 0 ).lower(), QString( "id" ) ); - c.setName( qTableName( "qtest_precision" ) ); - QCOMPARE( c.name(), qTableName( "qtest_precision" ) ); + c.setName( qTableName( "qtest_precision", __FILE__ ) ); + QCOMPARE( c.name(), qTableName( "qtest_precision", __FILE__ ) ); QCOMPARE( c.fieldName( 0 ).lower(), QString( "col1" ) ); } @@ -689,9 +690,9 @@ void tst_Q3SqlCursor::updateNoPK() CHECK_DATABASE( db ); QSqlQuery q(db); - QVERIFY_SQL(q, exec("create table " + qTableName( "qtestPK" ) + " (id int, name varchar(20), num numeric)")); + QVERIFY_SQL(q, exec("create table " + qTableName( "qtestPK", __FILE__ ) + " (id int, name varchar(20), num numeric)")); - Q3SqlCursor cur(qTableName("qtestPK"), true, db); + Q3SqlCursor cur(qTableName("qtestPK", __FILE__), true, db); QSqlRecord* rec = cur.primeInsert(); Q_ASSERT(rec); rec->setNull(0); @@ -705,14 +706,14 @@ void tst_Q3SqlCursor::updateNoPK() db.driverName().startsWith("QMYSQL") || db.driverName().startsWith("QODBC") || db.driverName().startsWith("QOCI")) { - QString query = QString::fromLatin1("insert into " + qTableName("qtestPK") + + QString query = QString::fromLatin1("insert into " + qTableName("qtestPK", __FILE__) + " (" + db.driver()->escapeIdentifier("id", QSqlDriver::FieldName) + ',' + db.driver()->escapeIdentifier("name", QSqlDriver::FieldName) + ',' + db.driver()->escapeIdentifier("num", QSqlDriver::FieldName) + ')' + " values (NULL,NULL,NULL)"); QCOMPARE(cur.lastQuery(), query); } else { - QCOMPARE(cur.lastQuery(), QString::fromLatin1("insert into " + qTableName("qtestPK") + + QCOMPARE(cur.lastQuery(), QString::fromLatin1("insert into " + qTableName("qtestPK", __FILE__) + " (\"id\",\"name\",\"num\") values (NULL,NULL,NULL)")); } } @@ -724,12 +725,12 @@ void tst_Q3SqlCursor::updateNoPK() rec->setNull(2); // Sqlite returns 2, don't ask why. QVERIFY(cur.update() != 0); - QString expect = "update " + qTableName("qtestPK") + + QString expect = "update " + qTableName("qtestPK", __FILE__) + " set "+db.driver()->escapeIdentifier("id", QSqlDriver::FieldName)+" = 1 , " +db.driver()->escapeIdentifier("name", QSqlDriver::FieldName)+" = NULL , " - +db.driver()->escapeIdentifier("num", QSqlDriver::FieldName)+" = NULL where " + qTableName("qtestPK") + ".id" - " IS NULL and " + qTableName("qtestPK") + ".name IS NULL and " + - qTableName("qtestPK") + ".num IS NULL"; + +db.driver()->escapeIdentifier("num", QSqlDriver::FieldName)+" = NULL where " + qTableName("qtestPK", __FILE__) + ".id" + " IS NULL and " + qTableName("qtestPK", __FILE__) + ".name IS NULL and " + + qTableName("qtestPK", __FILE__) + ".num IS NULL"; if (!db.driver()->hasFeature(QSqlDriver::PreparedQueries)) { if (!db.driverName().startsWith("QSQLITE")) { QCOMPARE(cur.lastQuery(), expect); @@ -760,7 +761,7 @@ void tst_Q3SqlCursor::insertFieldNameContainsWS() { return; } - QString tableName = qTableName("qtestws"); + QString tableName = qTableName("qtestws", __FILE__); QSqlQuery q(db); tst_Databases::safeDropTable(db, tableName); diff --git a/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp b/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp index c19f9fd..b69ae79 100644 --- a/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp +++ b/tests/auto/q3sqlselectcursor/tst_q3sqlselectcursor.cpp @@ -111,16 +111,16 @@ void tst_Q3SqlSelectCursor::createTestTables( QSqlDatabase db ) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); // please never ever change this table; otherwise fix all tests ;) if (tst_Databases::isMSAccess(db)) - QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest" ) + " ( id int not null, t_varchar varchar(40) not null," + QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest", __FILE__ ) + " ( id int not null, t_varchar varchar(40) not null," "t_char char(40), t_numeric number, primary key (id, t_varchar) )" )); else - QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest" ) + " ( id int not null, t_varchar varchar(40) not null," + QVERIFY_SQL(q, exec( "create table " + qTableName( "qtest", __FILE__ ) + " ( id int not null, t_varchar varchar(40) not null," "t_char char(40), t_numeric numeric(6, 3), primary key (id, t_varchar) )" )); } void tst_Q3SqlSelectCursor::dropTestTables( QSqlDatabase db ) { - tst_Databases::safeDropTable( db, qTableName( "qtest" ) ); + tst_Databases::safeDropTable( db, qTableName( "qtest", __FILE__ ) ); } void tst_Q3SqlSelectCursor::populateTestTables( QSqlDatabase db ) @@ -129,11 +129,11 @@ void tst_Q3SqlSelectCursor::populateTestTables( QSqlDatabase db ) return; QSqlQuery q( db ); - q.exec( "delete from " + qTableName( "qtest" ) ); //non-fatal - QVERIFY_SQL(q, exec( "insert into " + qTableName( "qtest" ) + " (id, t_varchar, t_char, t_numeric) values ( 0, 'VarChar0', 'Char0', 1.1 )" )); - QVERIFY_SQL(q, exec( "insert into " + qTableName( "qtest" ) + " (id, t_varchar, t_char, t_numeric) values ( 1, 'VarChar1', 'Char1', 2.2 )" )); - QVERIFY_SQL(q, exec( "insert into " + qTableName( "qtest" ) + " (id, t_varchar, t_char, t_numeric) values ( 2, 'VarChar2', 'Char2', 3.3 )" )); - QVERIFY_SQL(q, exec( "insert into " + qTableName( "qtest" ) + " (id, t_varchar, t_char, t_numeric) values ( 3, 'VarChar3', 'Char3', 4.4 )" )); + q.exec( "delete from " + qTableName( "qtest", __FILE__ ) ); //non-fatal + QVERIFY_SQL(q, exec( "insert into " + qTableName( "qtest", __FILE__ ) + " (id, t_varchar, t_char, t_numeric) values ( 0, 'VarChar0', 'Char0', 1.1 )" )); + QVERIFY_SQL(q, exec( "insert into " + qTableName( "qtest", __FILE__ ) + " (id, t_varchar, t_char, t_numeric) values ( 1, 'VarChar1', 'Char1', 2.2 )" )); + QVERIFY_SQL(q, exec( "insert into " + qTableName( "qtest", __FILE__ ) + " (id, t_varchar, t_char, t_numeric) values ( 2, 'VarChar2', 'Char2', 3.3 )" )); + QVERIFY_SQL(q, exec( "insert into " + qTableName( "qtest", __FILE__ ) + " (id, t_varchar, t_char, t_numeric) values ( 3, 'VarChar3', 'Char3', 4.4 )" )); } void tst_Q3SqlSelectCursor::initTestCase() @@ -184,7 +184,7 @@ void tst_Q3SqlSelectCursor::value() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); - Q3SqlSelectCursor cur( "select * from " + qTableName( "qtest" ) + " order by id", db ); + Q3SqlSelectCursor cur( "select * from " + qTableName( "qtest", __FILE__ ) + " order by id", db ); QVERIFY( cur.select() ); QVERIFY_SQL(cur, isActive()); int i = 0; @@ -203,7 +203,7 @@ void tst_Q3SqlSelectCursor::_exec() Q3SqlSelectCursor cur( QString(), db ); QVERIFY_SQL(cur, isActive() == false); - cur.exec( "select * from " + qTableName( "qtest" ) ); //nothing should happen + cur.exec( "select * from " + qTableName( "qtest", __FILE__ ) ); //nothing should happen QVERIFY_SQL(cur, isActive()); int i = 0; while ( cur.next() ) { diff --git a/tests/auto/qabstractslider/tst_qabstractslider.cpp b/tests/auto/qabstractslider/tst_qabstractslider.cpp index 293af36..cf069db 100644 --- a/tests/auto/qabstractslider/tst_qabstractslider.cpp +++ b/tests/auto/qabstractslider/tst_qabstractslider.cpp @@ -728,7 +728,12 @@ void tst_QAbstractSlider::wheelEvent_data() << 1 // delta << int(Qt::Vertical) // orientation of slider << int(Qt::Vertical) // orientation of wheel +#ifndef Q_WS_MAC << 1 // expected position after +#else + // We don't restrict scrolling to pageStep on Mac + << 100 // expected position after +#endif << QPoint(1,1); QTest::newRow("Different orientation") << 0 // initial position @@ -742,7 +747,12 @@ void tst_QAbstractSlider::wheelEvent_data() << 1 // delta << int(Qt::Horizontal) // orientation of slider << int(Qt::Vertical) // orientation of wheel +#ifndef Q_WS_MAC << 1 // expected position after +#else + // We don't restrict scrolling to pageStep on Mac + << 100 // expected position after +#endif << QPoint(1,1); QTest::newRow("Different orientation2")<< 0 // initial position @@ -756,7 +766,12 @@ void tst_QAbstractSlider::wheelEvent_data() << 1 // delta << int(Qt::Horizontal) // orientation of slider << int(Qt::Vertical) // orientation of wheel +#ifndef Q_WS_MAC << 1 // expected position after +#else + // We don't restrict scrolling to pageStep on Mac + << 100 // expected position after +#endif << QPoint(0,0); diff --git a/tests/auto/qdbuscontext/tst_qdbuscontext.cpp b/tests/auto/qdbuscontext/tst_qdbuscontext.cpp index be62d5b..2b7ac06 100644 --- a/tests/auto/qdbuscontext/tst_qdbuscontext.cpp +++ b/tests/auto/qdbuscontext/tst_qdbuscontext.cpp @@ -47,7 +47,7 @@ const char errorMsg[] = "A generic error"; class TestObject: public QObject, protected QDBusContext { Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "com.trolltech.tst_QDBusContext.TestObject"); + Q_CLASSINFO("D-Bus Interface", "com.trolltech.tst_QDBusContext.TestObject") public: inline TestObject(QObject *parent) : QObject(parent) { } public Q_SLOTS: diff --git a/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp b/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp index d750c69..af0ed76 100644 --- a/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp +++ b/tests/auto/qdeclarativeaudio/tst_qdeclarativeaudio.cpp @@ -49,7 +49,7 @@ #include <QtMultimedia/qmetadatacontrol.h> -class tst_QmlAudio : public QObject +class tst_QDeclarativeAudio : public QObject { Q_OBJECT public slots: @@ -61,6 +61,7 @@ private slots: void nullService(); void source(); + void autoLoad(); void playing(); void paused(); void duration(); @@ -284,12 +285,12 @@ public: }; -void tst_QmlAudio::initTestCase() +void tst_QDeclarativeAudio::initTestCase() { qRegisterMetaType<QDeclarativeAudio::Error>(); } -void tst_QmlAudio::nullPlayerControl() +void tst_QDeclarativeAudio::nullPlayerControl() { QtTestMetaDataControl metaDataControl; QtTestMediaServiceProvider provider(0, &metaDataControl); @@ -298,11 +299,12 @@ void tst_QmlAudio::nullPlayerControl() QCOMPARE(audio.source(), QUrl()); audio.setSource(QUrl("http://example.com")); - QCOMPARE(audio.source(), QUrl()); + QCOMPARE(audio.source(), QUrl("http://example.com")); QCOMPARE(audio.isPlaying(), false); audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), false); + QCOMPARE(audio.isPlaying(), true); + audio.setPlaying(false); audio.play(); QCOMPARE(audio.isPlaying(), false); @@ -316,15 +318,15 @@ void tst_QmlAudio::nullPlayerControl() QCOMPARE(audio.position(), 0); audio.setPosition(10000); - QCOMPARE(audio.position(), 0); + QCOMPARE(audio.position(), 10000); - QCOMPARE(audio.volume(), qreal(0)); - audio.setVolume(50); - QCOMPARE(audio.volume(), qreal(0)); + QCOMPARE(audio.volume(), qreal(1.0)); + audio.setVolume(0.5); + QCOMPARE(audio.volume(), qreal(0.5)); QCOMPARE(audio.isMuted(), false); audio.setMuted(true); - QCOMPARE(audio.isMuted(), false); + QCOMPARE(audio.isMuted(), true); QCOMPARE(audio.bufferProgress(), qreal(0)); @@ -337,7 +339,7 @@ void tst_QmlAudio::nullPlayerControl() QCOMPARE(audio.error(), QDeclarativeAudio::ServiceMissing); } -void tst_QmlAudio::nullMetaDataControl() +void tst_QDeclarativeAudio::nullMetaDataControl() { QtTestMediaPlayerControl playerControl; QtTestMediaServiceProvider provider(&playerControl, 0); @@ -349,7 +351,7 @@ void tst_QmlAudio::nullMetaDataControl() QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1); } -void tst_QmlAudio::nullService() +void tst_QDeclarativeAudio::nullService() { QtTestMediaServiceProvider provider(0); @@ -357,11 +359,12 @@ void tst_QmlAudio::nullService() QCOMPARE(audio.source(), QUrl()); audio.setSource(QUrl("http://example.com")); - QCOMPARE(audio.source(), QUrl()); + QCOMPARE(audio.source(), QUrl("http://example.com")); QCOMPARE(audio.isPlaying(), false); audio.setPlaying(true); - QCOMPARE(audio.isPlaying(), false); + QCOMPARE(audio.isPlaying(), true); + audio.setPlaying(false); audio.play(); QCOMPARE(audio.isPlaying(), false); @@ -375,15 +378,15 @@ void tst_QmlAudio::nullService() QCOMPARE(audio.position(), 0); audio.setPosition(10000); - QCOMPARE(audio.position(), 0); + QCOMPARE(audio.position(), 10000); - QCOMPARE(audio.volume(), qreal(0)); - audio.setVolume(50); - QCOMPARE(audio.volume(), qreal(0)); + QCOMPARE(audio.volume(), qreal(1.0)); + audio.setVolume(0.5); + QCOMPARE(audio.volume(), qreal(0.5)); QCOMPARE(audio.isMuted(), false); audio.setMuted(true); - QCOMPARE(audio.isMuted(), false); + QCOMPARE(audio.isMuted(), true); QCOMPARE(audio.bufferProgress(), qreal(0)); @@ -400,7 +403,7 @@ void tst_QmlAudio::nullService() QCOMPARE(audio.metaObject()->indexOfProperty("description"), -1); } -void tst_QmlAudio::source() +void tst_QDeclarativeAudio::source() { const QUrl url1("http://example.com"); const QUrl url2("file:///local/path"); @@ -408,6 +411,7 @@ void tst_QmlAudio::source() QtTestMediaServiceProvider provider; QDeclarativeAudio audio; + audio.componentComplete(); QSignalSpy spy(&audio, SIGNAL(sourceChanged())); @@ -427,7 +431,34 @@ void tst_QmlAudio::source() QCOMPARE(spy.count(), 3); } -void tst_QmlAudio::playing() +void tst_QDeclarativeAudio::autoLoad() +{ + QtTestMediaServiceProvider provider; + QDeclarativeAudio audio; + audio.componentComplete(); + + QSignalSpy spy(&audio, SIGNAL(autoLoadChanged())); + + QCOMPARE(audio.isAutoLoad(), true); + + audio.setAutoLoad(false); + QCOMPARE(audio.isAutoLoad(), false); + QCOMPARE(spy.count(), 1); + + audio.setSource(QUrl("http://example.com")); + QCOMPARE(audio.source(), QUrl("http://example.com")); + audio.play(); + QCOMPARE(audio.isPlaying(), true); + audio.stop(); + + audio.setAutoLoad(true); + audio.setSource(QUrl("http://example.com")); + audio.setPaused(true); + QCOMPARE(spy.count(), 2); + QCOMPARE(audio.isPaused(), true); +} + +void tst_QDeclarativeAudio::playing() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; @@ -440,6 +471,8 @@ void tst_QmlAudio::playing() int started = 0; int stopped = 0; + audio.componentComplete(); + QCOMPARE(audio.isPlaying(), false); // setPlaying(true) when stopped. @@ -514,7 +547,7 @@ void tst_QmlAudio::playing() QCOMPARE(stoppedSpy.count(), stopped); } -void tst_QmlAudio::paused() +void tst_QDeclarativeAudio::paused() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; @@ -533,6 +566,8 @@ void tst_QmlAudio::paused() int resumed = 0; int stopped = 0; + audio.componentComplete(); + QCOMPARE(audio.isPlaying(), false); QCOMPARE(audio.isPaused(), false); @@ -801,11 +836,13 @@ void tst_QmlAudio::paused() QCOMPARE(stoppedSpy.count(), stopped); } -void tst_QmlAudio::duration() +void tst_QDeclarativeAudio::duration() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; + audio.componentComplete(); + QSignalSpy spy(&audio, SIGNAL(durationChanged())); QCOMPARE(audio.duration(), 0); @@ -828,10 +865,11 @@ void tst_QmlAudio::duration() QCOMPARE(spy.count(), 4); } -void tst_QmlAudio::position() +void tst_QDeclarativeAudio::position() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; + audio.componentComplete(); QSignalSpy spy(&audio, SIGNAL(positionChanged())); @@ -853,32 +891,33 @@ void tst_QmlAudio::position() audio.setPosition(-5403); QCOMPARE(audio.position(), -5403); QCOMPARE(provider.playerControl()->position(), qint64(-5403)); - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.count(), 2); // Check the signal change signal is emitted if the change originates from the media service. provider.playerControl()->setPosition(0); QCOMPARE(audio.position(), 0); - QCOMPARE(spy.count(), 4); + QCOMPARE(spy.count(), 3); connect(&audio, SIGNAL(positionChanged()), &QTestEventLoop::instance(), SLOT(exitLoop())); provider.playerControl()->updateState(QMediaPlayer::PlayingState); QTestEventLoop::instance().enterLoop(1); - QVERIFY(spy.count() > 4 && spy.count() < 7); // 5 or 6 + QVERIFY(spy.count() > 3 && spy.count() < 6); // 4 or 5 provider.playerControl()->updateState(QMediaPlayer::PausedState); QTestEventLoop::instance().enterLoop(1); - QVERIFY(spy.count() < 7); + QVERIFY(spy.count() < 6); } -void tst_QmlAudio::volume() +void tst_QDeclarativeAudio::volume() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; + audio.componentComplete(); QSignalSpy spy(&audio, SIGNAL(volumeChanged())); - QCOMPARE(audio.volume(), qreal(0.5)); + QCOMPARE(audio.volume(), qreal(1.0)); audio.setVolume(0.7); QCOMPARE(audio.volume(), qreal(0.7)); @@ -888,17 +927,18 @@ void tst_QmlAudio::volume() audio.setVolume(0.7); QCOMPARE(audio.volume(), qreal(0.7)); QCOMPARE(provider.playerControl()->volume(), 70); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.count(), 1); provider.playerControl()->setVolume(30); QCOMPARE(audio.volume(), qreal(0.3)); - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.count(), 2); } -void tst_QmlAudio::muted() +void tst_QDeclarativeAudio::muted() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; + audio.componentComplete(); QSignalSpy spy(&audio, SIGNAL(mutedChanged())); @@ -919,11 +959,13 @@ void tst_QmlAudio::muted() QCOMPARE(spy.count(), 3); } -void tst_QmlAudio::bufferProgress() +void tst_QDeclarativeAudio::bufferProgress() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; + audio.componentComplete(); + QSignalSpy spy(&audio, SIGNAL(bufferProgressChanged())); QCOMPARE(audio.bufferProgress(), qreal(0.0)); @@ -952,11 +994,13 @@ void tst_QmlAudio::bufferProgress() QVERIFY(spy.count() < 6); } -void tst_QmlAudio::seekable() +void tst_QDeclarativeAudio::seekable() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; + audio.componentComplete(); + QSignalSpy spy(&audio, SIGNAL(seekableChanged())); QCOMPARE(audio.isSeekable(), false); @@ -974,11 +1018,13 @@ void tst_QmlAudio::seekable() QCOMPARE(spy.count(), 3); } -void tst_QmlAudio::playbackRate() +void tst_QDeclarativeAudio::playbackRate() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; + audio.componentComplete(); + QSignalSpy spy(&audio, SIGNAL(playbackRateChanged())); QCOMPARE(audio.playbackRate(), qreal(1.0)); @@ -998,11 +1044,13 @@ void tst_QmlAudio::playbackRate() QCOMPARE(spy.count(), 3); } -void tst_QmlAudio::status() +void tst_QDeclarativeAudio::status() { QtTestMediaServiceProvider provider; QDeclarativeAudio audio; + audio.componentComplete(); + QSignalSpy statusChangedSpy(&audio, SIGNAL(statusChanged())); QSignalSpy loadedSpy(&audio, SIGNAL(loaded())); QSignalSpy bufferingSpy(&audio, SIGNAL(buffering())); @@ -1105,7 +1153,7 @@ void tst_QmlAudio::status() QCOMPARE(endOfMediaSpy.count(), 1); } -void tst_QmlAudio::metaData_data() +void tst_QDeclarativeAudio::metaData_data() { QTest::addColumn<QByteArray>("propertyName"); QTest::addColumn<QtMultimedia::MetaData>("propertyKey"); @@ -1131,7 +1179,7 @@ void tst_QmlAudio::metaData_data() << QVariant(12); } -void tst_QmlAudio::metaData() +void tst_QDeclarativeAudio::metaData() { QFETCH(QByteArray, propertyName); QFETCH(QtMultimedia::MetaData, propertyKey); @@ -1141,6 +1189,8 @@ void tst_QmlAudio::metaData() QtTestMediaServiceProvider provider; QDeclarativeAudio audio; + audio.componentComplete(); + QSignalSpy spy(&audio, SIGNAL(__metaDataChanged())); const int index = audio.metaObject()->indexOfProperty(propertyName.constData()); @@ -1159,13 +1209,15 @@ void tst_QmlAudio::metaData() QCOMPARE(spy.count(), 2); } -void tst_QmlAudio::error() +void tst_QDeclarativeAudio::error() { const QString errorString = QLatin1String("Failed to open device."); QtTestMediaServiceProvider provider; QDeclarativeAudio audio; + audio.componentComplete(); + QSignalSpy errorSpy(&audio, SIGNAL(error(QDeclarativeAudio::Error,QString))); QSignalSpy errorChangedSpy(&audio, SIGNAL(errorChanged())); @@ -1195,6 +1247,6 @@ void tst_QmlAudio::error() } -QTEST_MAIN(tst_QmlAudio) +QTEST_MAIN(tst_QDeclarativeAudio) #include "tst_qdeclarativeaudio.moc" diff --git a/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp b/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp index 5fd3675..0fbd78c 100644 --- a/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp +++ b/tests/auto/qdeclarativevideo/tst_qdeclarativevideo.cpp @@ -53,7 +53,7 @@ #include <QtMultimedia/qvideosurfaceformat.h> -class tst_QmlGraphicsVideo : public QObject +class tst_QDeclarativeVideo : public QObject { Q_OBJECT public slots: @@ -291,12 +291,12 @@ public: }; -void tst_QmlGraphicsVideo::initTestCase() +void tst_QDeclarativeVideo::initTestCase() { qRegisterMetaType<QDeclarativeVideo::Error>(); } -void tst_QmlGraphicsVideo::nullPlayerControl() +void tst_QDeclarativeVideo::nullPlayerControl() { QtTestMediaServiceProvider provider(0, 0, 0); @@ -304,11 +304,12 @@ void tst_QmlGraphicsVideo::nullPlayerControl() QCOMPARE(video.source(), QUrl()); video.setSource(QUrl("http://example.com")); - QCOMPARE(video.source(), QUrl()); + QCOMPARE(video.source(), QUrl("http://example.com")); QCOMPARE(video.isPlaying(), false); video.setPlaying(true); - QCOMPARE(video.isPlaying(), false); + QCOMPARE(video.isPlaying(), true); + video.setPlaying(false); video.play(); QCOMPARE(video.isPlaying(), false); @@ -322,15 +323,15 @@ void tst_QmlGraphicsVideo::nullPlayerControl() QCOMPARE(video.position(), 0); video.setPosition(10000); - QCOMPARE(video.position(), 0); + QCOMPARE(video.position(), 10000); - QCOMPARE(video.volume(), qreal(0)); - video.setVolume(50); - QCOMPARE(video.volume(), qreal(0)); + QCOMPARE(video.volume(), qreal(1.0)); + video.setVolume(0.5); + QCOMPARE(video.volume(), qreal(0.5)); QCOMPARE(video.isMuted(), false); video.setMuted(true); - QCOMPARE(video.isMuted(), false); + QCOMPARE(video.isMuted(), true); QCOMPARE(video.bufferProgress(), qreal(0)); @@ -346,7 +347,7 @@ void tst_QmlGraphicsVideo::nullPlayerControl() QCOMPARE(video.error(), QDeclarativeVideo::ServiceMissing); } -void tst_QmlGraphicsVideo::nullService() +void tst_QDeclarativeVideo::nullService() { QtTestMediaServiceProvider provider(0); @@ -354,11 +355,12 @@ void tst_QmlGraphicsVideo::nullService() QCOMPARE(video.source(), QUrl()); video.setSource(QUrl("http://example.com")); - QCOMPARE(video.source(), QUrl()); + QCOMPARE(video.source(), QUrl("http://example.com")); QCOMPARE(video.isPlaying(), false); video.setPlaying(true); - QCOMPARE(video.isPlaying(), false); + QCOMPARE(video.isPlaying(), true); + video.setPlaying(false); video.play(); QCOMPARE(video.isPlaying(), false); @@ -372,15 +374,15 @@ void tst_QmlGraphicsVideo::nullService() QCOMPARE(video.position(), 0); video.setPosition(10000); - QCOMPARE(video.position(), 0); + QCOMPARE(video.position(), 10000); - QCOMPARE(video.volume(), qreal(0)); - video.setVolume(50); - QCOMPARE(video.volume(), qreal(0)); + QCOMPARE(video.volume(), qreal(1.0)); + video.setVolume(0.5); + QCOMPARE(video.volume(), qreal(0.5)); QCOMPARE(video.isMuted(), false); video.setMuted(true); - QCOMPARE(video.isMuted(), false); + QCOMPARE(video.isMuted(), true); QCOMPARE(video.bufferProgress(), qreal(0)); @@ -400,10 +402,11 @@ void tst_QmlGraphicsVideo::nullService() QCOMPARE(video.metaObject()->indexOfProperty("description"), -1); } -void tst_QmlGraphicsVideo::playing() +void tst_QDeclarativeVideo::playing() { QtTestMediaServiceProvider provider; QDeclarativeVideo video; + video.componentComplete(); QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged())); QSignalSpy startedSpy(&video, SIGNAL(started())); @@ -487,10 +490,11 @@ void tst_QmlGraphicsVideo::playing() QCOMPARE(stoppedSpy.count(), stopped); } -void tst_QmlGraphicsVideo::paused() +void tst_QDeclarativeVideo::paused() { QtTestMediaServiceProvider provider; QDeclarativeVideo video; + video.componentComplete(); QSignalSpy playingChangedSpy(&video, SIGNAL(playingChanged())); QSignalSpy pausedChangedSpy(&video, SIGNAL(pausedChanged())); @@ -774,12 +778,13 @@ void tst_QmlGraphicsVideo::paused() QCOMPARE(stoppedSpy.count(), stopped); } -void tst_QmlGraphicsVideo::error() +void tst_QDeclarativeVideo::error() { const QString errorString = QLatin1String("Failed to open device."); QtTestMediaServiceProvider provider; QDeclarativeVideo video; + video.componentComplete(); QSignalSpy errorSpy(&video, SIGNAL(error(QDeclarativeVideo::Error,QString))); QSignalSpy errorChangedSpy(&video, SIGNAL(errorChanged())); @@ -810,10 +815,11 @@ void tst_QmlGraphicsVideo::error() } -void tst_QmlGraphicsVideo::hasAudio() +void tst_QDeclarativeVideo::hasAudio() { QtTestMediaServiceProvider provider; QDeclarativeVideo video; + video.componentComplete(); QSignalSpy spy(&video, SIGNAL(hasAudioChanged())); @@ -832,11 +838,13 @@ void tst_QmlGraphicsVideo::hasAudio() QCOMPARE(spy.count(), 3); } -void tst_QmlGraphicsVideo::hasVideo() +void tst_QDeclarativeVideo::hasVideo() { QtTestMediaServiceProvider provider; QDeclarativeVideo video; + video.componentComplete(); + QSignalSpy spy(&video, SIGNAL(hasVideoChanged())); QCOMPARE(video.hasVideo(), false); @@ -854,10 +862,11 @@ void tst_QmlGraphicsVideo::hasVideo() QCOMPARE(spy.count(), 3); } -void tst_QmlGraphicsVideo::fillMode() +void tst_QDeclarativeVideo::fillMode() { QtTestMediaServiceProvider provider; QDeclarativeVideo video; + video.componentComplete(); QList<QGraphicsItem *> children = video.childItems(); QCOMPARE(children.count(), 1); @@ -879,10 +888,11 @@ void tst_QmlGraphicsVideo::fillMode() QCOMPARE(videoItem->aspectRatioMode(), Qt::KeepAspectRatio); } -void tst_QmlGraphicsVideo::geometry() +void tst_QDeclarativeVideo::geometry() { QtTestMediaServiceProvider provider; QDeclarativeVideo video; + video.componentComplete(); QAbstractVideoSurface *surface = provider.rendererControl()->surface(); QVERIFY(surface != 0); @@ -906,6 +916,6 @@ void tst_QmlGraphicsVideo::geometry() QCOMPARE(videoItem->size().height(), qreal(328)); } -QTEST_MAIN(tst_QmlGraphicsVideo) +QTEST_MAIN(tst_QDeclarativeVideo) #include "tst_qdeclarativevideo.moc" diff --git a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp index f2e1dbd..6bfa8be 100644 --- a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp @@ -87,13 +87,13 @@ public: } }; -class tst_QFiledialog : public QObject +class tst_QFileDialog2 : public QObject { Q_OBJECT public: - tst_QFiledialog(); - virtual ~tst_QFiledialog(); + tst_QFileDialog2(); + virtual ~tst_QFileDialog2(); public slots: void init(); @@ -138,18 +138,18 @@ private: QByteArray userSettings; }; -tst_QFiledialog::tst_QFiledialog() +tst_QFileDialog2::tst_QFileDialog2() { #if defined(Q_OS_WINCE) qApp->setAutoMaximizeThreshold(-1); #endif } -tst_QFiledialog::~tst_QFiledialog() +tst_QFileDialog2::~tst_QFileDialog2() { } -void tst_QFiledialog::init() +void tst_QFileDialog2::init() { // Save the developers settings so they don't get mad when their sidebar folders are gone. QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); @@ -164,14 +164,14 @@ void tst_QFiledialog::init() #endif } -void tst_QFiledialog::cleanup() +void tst_QFileDialog2::cleanup() { QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("Qt")); settings.setValue(QLatin1String("filedialog"), userSettings); } -void tst_QFiledialog::listRoot() +void tst_QFileDialog2::listRoot() { #if defined QT_BUILD_INTERNAL QFileInfoGatherer fileInfoGatherer; @@ -193,7 +193,7 @@ void tst_QFiledialog::listRoot() #endif } -void tst_QFiledialog::heapCorruption() +void tst_QFileDialog2::heapCorruption() { QVector<QNonNativeFileDialog*> dialogs; for (int i=0; i < 10; i++) { @@ -205,12 +205,12 @@ void tst_QFiledialog::heapCorruption() struct FriendlyQFileDialog : public QNonNativeFileDialog { - friend class tst_QFileDialog; + friend class tst_QFileDialog2; Q_DECLARE_PRIVATE(QFileDialog) }; -void tst_QFiledialog::deleteDirAndFiles() +void tst_QFileDialog2::deleteDirAndFiles() { #if defined QT_BUILD_INTERNAL QString tempPath = QDir::tempPath() + '/' + "QFileDialogTestDir4FullDelete"; @@ -242,7 +242,7 @@ void tst_QFiledialog::deleteDirAndFiles() #endif } -void tst_QFiledialog::filter() +void tst_QFileDialog2::filter() { QNonNativeFileDialog fd; QAction *hiddenAction = qFindChild<QAction*>(&fd, "qt_show_hidden_action"); @@ -255,7 +255,7 @@ void tst_QFiledialog::filter() QVERIFY(hiddenAction->isChecked()); } -void tst_QFiledialog::showNameFilterDetails() +void tst_QFileDialog2::showNameFilterDetails() { QNonNativeFileDialog fd; QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo"); @@ -280,7 +280,7 @@ void tst_QFiledialog::showNameFilterDetails() QCOMPARE(filters->itemText(2), filterChoices.at(2)); } -void tst_QFiledialog::unc() +void tst_QFileDialog2::unc() { #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) // Only test UNC on Windows./ @@ -295,7 +295,7 @@ void tst_QFiledialog::unc() QCOMPARE(model->index(fd.directory().absolutePath()), model->index(dir)); } -void tst_QFiledialog::emptyUncPath() +void tst_QFileDialog2::emptyUncPath() { QNonNativeFileDialog fd; fd.show(); @@ -308,7 +308,7 @@ void tst_QFiledialog::emptyUncPath() QVERIFY(model); } -void tst_QFiledialog::task178897_minimumSize() +void tst_QFileDialog2::task178897_minimumSize() { QNonNativeFileDialog fd; QSize oldMs = fd.layout()->minimumSize(); @@ -322,7 +322,7 @@ void tst_QFiledialog::task178897_minimumSize() QVERIFY(ms.width() <= oldMs.width()); } -void tst_QFiledialog::task180459_lastDirectory_data() +void tst_QFileDialog2::task180459_lastDirectory_data() { QTest::addColumn<QString>("path"); QTest::addColumn<QString>("directory"); @@ -345,7 +345,7 @@ void tst_QFiledialog::task180459_lastDirectory_data() } -void tst_QFiledialog::task180459_lastDirectory() +void tst_QFileDialog2::task180459_lastDirectory() { //first visit the temp directory and close the dialog QNonNativeFileDialog *dlg = new QNonNativeFileDialog(0, "", QDir::tempPath()); @@ -449,7 +449,7 @@ QString &dir, const QString &filter) } }; -void tst_QFiledialog::task227304_proxyOnFileDialog() +void tst_QFileDialog2::task227304_proxyOnFileDialog() { #if defined QT_BUILD_INTERNAL QNonNativeFileDialog fd(0, "", QDir::currentPath(), 0); @@ -488,7 +488,7 @@ void tst_QFiledialog::task227304_proxyOnFileDialog() #endif } -void tst_QFiledialog::task227930_correctNavigationKeyboardBehavior() +void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior() { QDir current = QDir::currentPath(); current.mkdir("test"); @@ -527,7 +527,7 @@ void tst_QFiledialog::task227930_correctNavigationKeyboardBehavior() } #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -void tst_QFiledialog::task226366_lowerCaseHardDriveWindows() +void tst_QFileDialog2::task226366_lowerCaseHardDriveWindows() { QNonNativeFileDialog fd; fd.setDirectory(QDir::root().path()); @@ -553,7 +553,7 @@ void tst_QFiledialog::task226366_lowerCaseHardDriveWindows() } #endif -void tst_QFiledialog::completionOnLevelAfterRoot() +void tst_QFileDialog2::completionOnLevelAfterRoot() { QNonNativeFileDialog fd; #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) @@ -592,7 +592,7 @@ void tst_QFiledialog::completionOnLevelAfterRoot() #endif } -void tst_QFiledialog::task233037_selectingDirectory() +void tst_QFileDialog2::task233037_selectingDirectory() { QDir current = QDir::currentPath(); current.mkdir("test"); @@ -615,7 +615,7 @@ void tst_QFiledialog::task233037_selectingDirectory() current.rmdir("test"); } -void tst_QFiledialog::task235069_hideOnEscape() +void tst_QFileDialog2::task235069_hideOnEscape() { QDir current = QDir::currentPath(); QNonNativeFileDialog fd; @@ -637,7 +637,7 @@ void tst_QFiledialog::task235069_hideOnEscape() QCOMPARE(fd2.isVisible(), false); } -void tst_QFiledialog::task236402_dontWatchDeletedDir() +void tst_QFileDialog2::task236402_dontWatchDeletedDir() { #if defined QT_BUILD_INTERNAL //THIS TEST SHOULD NOT DISPLAY WARNINGS @@ -662,7 +662,7 @@ void tst_QFiledialog::task236402_dontWatchDeletedDir() #endif } -void tst_QFiledialog::task203703_returnProperSeparator() +void tst_QFileDialog2::task203703_returnProperSeparator() { QDir current = QDir::currentPath(); current.mkdir("aaaaaaaaaaaaaaaaaa"); @@ -687,7 +687,7 @@ void tst_QFiledialog::task203703_returnProperSeparator() current.rmdir("aaaaaaaaaaaaaaaaaa"); } -void tst_QFiledialog::task228844_ensurePreviousSorting() +void tst_QFileDialog2::task228844_ensurePreviousSorting() { QDir current = QDir::currentPath(); current.mkdir("aaaaaaaaaaaaaaaaaa"); @@ -789,7 +789,7 @@ void tst_QFiledialog::task228844_ensurePreviousSorting() } -void tst_QFiledialog::task239706_editableFilterCombo() +void tst_QFileDialog2::task239706_editableFilterCombo() { QNonNativeFileDialog d; d.setNameFilter("*.cpp *.h"); @@ -812,7 +812,7 @@ void tst_QFiledialog::task239706_editableFilterCombo() QTest::keyPress(filterCombo, Qt::Key_Enter); // should not trigger assertion failure } -void tst_QFiledialog::task218353_relativePaths() +void tst_QFileDialog2::task218353_relativePaths() { QDir appDir = QDir::current(); QVERIFY(appDir.cdUp() != false); @@ -829,7 +829,7 @@ void tst_QFiledialog::task218353_relativePaths() appDir.rmdir("test"); } -void tst_QFiledialog::task251321_sideBarHiddenEntries() +void tst_QFileDialog2::task251321_sideBarHiddenEntries() { #if defined QT_BUILD_INTERNAL QNonNativeFileDialog fd; @@ -889,7 +889,7 @@ public : }; #endif -void tst_QFiledialog::task251341_sideBarRemoveEntries() +void tst_QFileDialog2::task251341_sideBarRemoveEntries() { #if defined QT_BUILD_INTERNAL QNonNativeFileDialog fd; @@ -954,7 +954,7 @@ void tst_QFiledialog::task251341_sideBarRemoveEntries() #endif } -void tst_QFiledialog::task254490_selectFileMultipleTimes() +void tst_QFileDialog2::task254490_selectFileMultipleTimes() { QString tempPath = QDir::tempPath(); QTemporaryFile *t; @@ -986,7 +986,7 @@ void tst_QFiledialog::task254490_selectFileMultipleTimes() t->deleteLater(); } -void tst_QFiledialog::task257579_sideBarWithNonCleanUrls() +void tst_QFileDialog2::task257579_sideBarWithNonCleanUrls() { #if defined QT_BUILD_INTERNAL QDir tempDir = QDir::temp(); @@ -1012,7 +1012,7 @@ void tst_QFiledialog::task257579_sideBarWithNonCleanUrls() #endif } -void tst_QFiledialog::task259105_filtersCornerCases() +void tst_QFileDialog2::task259105_filtersCornerCases() { QNonNativeFileDialog fd(0, "TestFileDialog"); fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)")); @@ -1056,7 +1056,7 @@ void tst_QFiledialog::task259105_filtersCornerCases() QCOMPARE(filters->currentText(), QLatin1String("Text Files")); } -void tst_QFiledialog::QTBUG4419_lineEditSelectAll() +void tst_QFileDialog2::QTBUG4419_lineEditSelectAll() { QString tempPath = QDir::tempPath(); QTemporaryFile *t; @@ -1082,7 +1082,7 @@ void tst_QFiledialog::QTBUG4419_lineEditSelectAll() QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), t->fileName()); } -void tst_QFiledialog::QTBUG6558_showDirsOnly() +void tst_QFileDialog2::QTBUG6558_showDirsOnly() { const QString tempPath = QDir::tempPath(); QDir dirTemp(tempPath); @@ -1148,7 +1148,7 @@ void tst_QFiledialog::QTBUG6558_showDirsOnly() dirTemp.rmdir(tempName); } -void tst_QFiledialog::QTBUG4842_selectFilterWithHideNameFilterDetails() +void tst_QFileDialog2::QTBUG4842_selectFilterWithHideNameFilterDetails() { QStringList filtersStr; filtersStr << "Images (*.png *.xpm *.jpg)" << "Text files (*.txt)" << "XML files (*.xml)"; @@ -1188,5 +1188,5 @@ void tst_QFiledialog::QTBUG4842_selectFilterWithHideNameFilterDetails() } -QTEST_MAIN(tst_QFiledialog) +QTEST_MAIN(tst_QFileDialog2) #include "tst_qfiledialog2.moc" diff --git a/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 901099d..7138905 100644 --- a/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -405,7 +405,7 @@ void tst_QFileSystemWatcher::removePaths() #if 0 class SignalTest : public QObject { - Q_OBJECT; + Q_OBJECT public slots: void fileSlot(const QString &file) { qDebug() << "file " << file;} void dirSlot(const QString &dir) { qDebug() << "dir" << dir;} diff --git a/tests/auto/qgl_threads/qgl_threads.pro b/tests/auto/qgl_threads/qgl_threads.pro deleted file mode 100644 index 9312c05..0000000 --- a/tests/auto/qgl_threads/qgl_threads.pro +++ /dev/null @@ -1,11 +0,0 @@ -############################################################ -# Project file for autotest for file qgl.h -############################################################ - -load(qttest_p4) -requires(contains(QT_CONFIG,opengl)) -QT += opengl - -HEADERS += tst_openglthreading.h -SOURCES += tst_openglthreading.cpp - diff --git a/tests/auto/qglthreads/qglthreads.pro b/tests/auto/qglthreads/qglthreads.pro new file mode 100644 index 0000000..4d20a19 --- /dev/null +++ b/tests/auto/qglthreads/qglthreads.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +requires(contains(QT_CONFIG,opengl)) +QT += opengl + +HEADERS += tst_qglthreads.h +SOURCES += tst_qglthreads.cpp + diff --git a/tests/auto/qgl_threads/tst_openglthreading.cpp b/tests/auto/qglthreads/tst_qglthreads.cpp index cf100cb..cce3161 100644 --- a/tests/auto/qgl_threads/tst_openglthreading.cpp +++ b/tests/auto/qglthreads/tst_qglthreads.cpp @@ -43,7 +43,7 @@ #include <QtCore/QtCore> #include <QtGui/QtGui> #include <QtOpenGL/QtOpenGL> -#include "tst_openglthreading.h" +#include "tst_qglthreads.h" #ifdef Q_WS_X11 #include <private/qt_x11_p.h> @@ -51,7 +51,7 @@ #define RUNNING_TIME 5000 -tst_OpenGLThreading::tst_OpenGLThreading(QObject *parent) +tst_QGLThreads::tst_QGLThreads(QObject *parent) : QObject(parent) { } @@ -143,7 +143,7 @@ public: SwapThread *m_thread; }; -void tst_OpenGLThreading::swapInThread() +void tst_QGLThreads::swapInThread() { #ifdef Q_OS_MAC QSKIP("OpenGL threading tests are currently disabled on mac as they were causing reboots", SkipAll); @@ -249,7 +249,7 @@ private: QList <QPoint> m_positions; }; -void tst_OpenGLThreading::textureUploadInThread() +void tst_QGLThreads::textureUploadInThread() { #ifdef Q_OS_MAC QSKIP("OpenGL threading tests are currently disabled on mac as they were causing reboots", SkipAll); @@ -412,7 +412,7 @@ private: QSize m_size; }; -void tst_OpenGLThreading::renderInThread_data() +void tst_QGLThreads::renderInThread_data() { QTest::addColumn<bool>("resize"); QTest::addColumn<bool>("update"); @@ -423,7 +423,7 @@ void tst_OpenGLThreading::renderInThread_data() QTest::newRow("with-resize-and-update") << true << true; } -void tst_OpenGLThreading::renderInThread() +void tst_QGLThreads::renderInThread() { #ifdef Q_OS_MAC QSKIP("OpenGL threading tests are currently disabled on mac as they were causing reboots", SkipAll); @@ -473,8 +473,8 @@ int main(int argc, char **argv) QApplication app(argc, argv); QTEST_DISABLE_KEYPAD_NAVIGATION \ - tst_OpenGLThreading tc; + tst_QGLThreads tc; return QTest::qExec(&tc, argc, argv); } -#include "tst_openglthreading.moc" +#include "tst_qglthreads.moc" diff --git a/tests/auto/qgl_threads/tst_openglthreading.h b/tests/auto/qglthreads/tst_qglthreads.h index c4b55cd..9e97909 100644 --- a/tests/auto/qgl_threads/tst_openglthreading.h +++ b/tests/auto/qglthreads/tst_qglthreads.h @@ -39,16 +39,16 @@ ** ****************************************************************************/ -#ifndef TST_OPENGLTHREADING_H -#define TST_OPENGLTHREADING_H +#ifndef TST_QGLTHREADS_H +#define TST_QGLTHREADS_H #include <QObject> -class tst_OpenGLThreading : public QObject +class tst_QGLThreads : public QObject { Q_OBJECT public: - explicit tst_OpenGLThreading(QObject *parent = 0); + explicit tst_QGLThreads(QObject *parent = 0); private slots: void swapInThread(); @@ -58,4 +58,4 @@ private slots: void renderInThread(); }; -#endif // TST_OPENGLTHREADING_H +#endif // TST_QGLTHREADS_H diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 16a621a..fa3e0f9 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -48,7 +48,7 @@ #include <QtGui/qwindowsstyle.h> class tst_QGraphicsAnchorLayout : public QObject { - Q_OBJECT; + Q_OBJECT public: tst_QGraphicsAnchorLayout() : QObject() { diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 4d9f23f..c0ad8bf 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -9767,6 +9767,9 @@ void tst_QGraphicsItem::scenePosChange() child1->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true); grandChild2->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true); + QVERIFY(child1->flags() & QGraphicsItem::ItemSendsScenePositionChanges); + QVERIFY(grandChild2->flags() & QGraphicsItem::ItemSendsScenePositionChanges); + QGraphicsScene scene; scene.addItem(root); diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 69d2ad2..23b3458 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -3426,85 +3426,106 @@ void tst_QGraphicsProxyWidget::clickFocus() scene.setItemIndexMethod(QGraphicsScene::NoIndex); QGraphicsProxyWidget *proxy = scene.addWidget(new QLineEdit); - EventSpy proxySpy(proxy); - EventSpy widgetSpy(proxy->widget()); - QGraphicsView view(&scene); - view.setFrameStyle(0); - view.resize(300, 300); - view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif - QApplication::setActiveWindow(&view); - QTest::qWait(25); - QTRY_COMPARE(QApplication::activeWindow(), &view); - QVERIFY(!proxy->hasFocus()); - QVERIFY(!proxy->widget()->hasFocus()); + { + EventSpy proxySpy(proxy); + EventSpy widgetSpy(proxy->widget()); - QCOMPARE(proxySpy.counts[QEvent::FocusIn], 0); - QCOMPARE(proxySpy.counts[QEvent::FocusOut], 0); - QCOMPARE(widgetSpy.counts[QEvent::FocusIn], 0); - QCOMPARE(widgetSpy.counts[QEvent::FocusOut], 0); + view.setFrameStyle(0); + view.resize(300, 300); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QApplication::setActiveWindow(&view); + QTest::qWait(25); + QTRY_COMPARE(QApplication::activeWindow(), &view); - QPointF lineEditCenter = proxy->mapToScene(proxy->boundingRect().center()); - // Spontaneous mouse click sets focus on a clickable widget. - for (int retry = 0; retry < 50 && !proxy->hasFocus(); retry++) - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(lineEditCenter)); - QVERIFY(proxy->hasFocus()); - QVERIFY(proxy->widget()->hasFocus()); - QCOMPARE(proxySpy.counts[QEvent::FocusIn], 1); - QCOMPARE(widgetSpy.counts[QEvent::FocusIn], 1); + QVERIFY(!proxy->hasFocus()); + QVERIFY(!proxy->widget()->hasFocus()); - scene.setFocusItem(0); - QVERIFY(!proxy->hasFocus()); - QVERIFY(!proxy->widget()->hasFocus()); - QCOMPARE(proxySpy.counts[QEvent::FocusOut], 1); - QCOMPARE(widgetSpy.counts[QEvent::FocusOut], 1); + QCOMPARE(proxySpy.counts[QEvent::FocusIn], 0); + QCOMPARE(proxySpy.counts[QEvent::FocusOut], 0); + QCOMPARE(widgetSpy.counts[QEvent::FocusIn], 0); + QCOMPARE(widgetSpy.counts[QEvent::FocusOut], 0); - // Non-spontaneous mouse click sets focus if the widget has been clicked before - { - QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); - event.setScenePos(lineEditCenter); - event.setButton(Qt::LeftButton); - qApp->sendEvent(&scene, &event); + QPointF lineEditCenter = proxy->mapToScene(proxy->boundingRect().center()); + // Spontaneous mouse click sets focus on a clickable widget. + for (int retry = 0; retry < 50 && !proxy->hasFocus(); retry++) + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(lineEditCenter)); QVERIFY(proxy->hasFocus()); QVERIFY(proxy->widget()->hasFocus()); - QCOMPARE(proxySpy.counts[QEvent::FocusIn], 2); - QCOMPARE(widgetSpy.counts[QEvent::FocusIn], 2); + QCOMPARE(proxySpy.counts[QEvent::FocusIn], 1); + QCOMPARE(widgetSpy.counts[QEvent::FocusIn], 1); + + scene.setFocusItem(0); + QVERIFY(!proxy->hasFocus()); + QVERIFY(!proxy->widget()->hasFocus()); + QCOMPARE(proxySpy.counts[QEvent::FocusOut], 1); + QCOMPARE(widgetSpy.counts[QEvent::FocusOut], 1); + + // Non-spontaneous mouse click sets focus if the widget has been clicked before + { + QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); + event.setScenePos(lineEditCenter); + event.setButton(Qt::LeftButton); + qApp->sendEvent(&scene, &event); + QVERIFY(proxy->hasFocus()); + QVERIFY(proxy->widget()->hasFocus()); + QCOMPARE(proxySpy.counts[QEvent::FocusIn], 2); + QCOMPARE(widgetSpy.counts[QEvent::FocusIn], 2); + } } scene.setFocusItem(0); proxy->setWidget(new QLineEdit); // resets focusWidget - QVERIFY(!proxy->hasFocus()); - QVERIFY(!proxy->widget()->hasFocus()); - QCOMPARE(proxySpy.counts[QEvent::FocusOut], 2); - QCOMPARE(widgetSpy.counts[QEvent::FocusOut], 2); - // Non-spontaneous mouse click does not set focus on the embedded widget. { - QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); - event.setScenePos(lineEditCenter); - event.setButton(Qt::LeftButton); - qApp->sendEvent(&scene, &event); + QPointF lineEditCenter = proxy->mapToScene(proxy->boundingRect().center()); + EventSpy proxySpy(proxy); + EventSpy widgetSpy(proxy->widget()); QVERIFY(!proxy->hasFocus()); QVERIFY(!proxy->widget()->hasFocus()); - QCOMPARE(proxySpy.counts[QEvent::FocusIn], 2); - QCOMPARE(widgetSpy.counts[QEvent::FocusIn], 2); - } + QCOMPARE(proxySpy.counts[QEvent::FocusOut], 0); + QCOMPARE(widgetSpy.counts[QEvent::FocusOut], 0); - scene.setFocusItem(0); - QVERIFY(!proxy->hasFocus()); - QVERIFY(!proxy->widget()->hasFocus()); - QCOMPARE(proxySpy.counts[QEvent::FocusOut], 2); - QCOMPARE(widgetSpy.counts[QEvent::FocusOut], 2); - - // Spontaneous click on non-clickable widget does not give focus. - proxy->widget()->setFocusPolicy(Qt::NoFocus); - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(lineEditCenter)); - QVERIFY(!proxy->hasFocus()); - QVERIFY(!proxy->widget()->hasFocus()); + // Non-spontaneous mouse click does not set focus on the embedded widget. + { + QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); + event.setScenePos(lineEditCenter); + event.setButton(Qt::LeftButton); + qApp->sendEvent(&scene, &event); + QVERIFY(!proxy->hasFocus()); + QVERIFY(!proxy->widget()->hasFocus()); + QCOMPARE(proxySpy.counts[QEvent::FocusIn], 0); + QCOMPARE(widgetSpy.counts[QEvent::FocusIn], 0); + } + + scene.setFocusItem(0); + QVERIFY(!proxy->hasFocus()); + QVERIFY(!proxy->widget()->hasFocus()); + QCOMPARE(proxySpy.counts[QEvent::FocusOut], 0); + QCOMPARE(widgetSpy.counts[QEvent::FocusOut], 0); + + // Spontaneous click on non-clickable widget does not give focus. + proxy->widget()->setFocusPolicy(Qt::NoFocus); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(lineEditCenter)); + QVERIFY(!proxy->hasFocus()); + QVERIFY(!proxy->widget()->hasFocus()); + + // Multiple clicks should only result in one FocusIn. + proxy->widget()->setFocusPolicy(Qt::StrongFocus); + scene.setFocusItem(0); + QVERIFY(!proxy->hasFocus()); + QVERIFY(!proxy->widget()->hasFocus()); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(lineEditCenter)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(lineEditCenter)); + QVERIFY(proxy->hasFocus()); + QVERIFY(proxy->widget()->hasFocus()); + QCOMPARE(widgetSpy.counts[QEvent::FocusIn], 1); + QCOMPARE(proxySpy.counts[QEvent::FocusIn], 1); + } } void tst_QGraphicsProxyWidget::windowFrameMargins() diff --git a/tests/auto/qheaderview/tst_qheaderview.cpp b/tests/auto/qheaderview/tst_qheaderview.cpp index 4642830..f6cd4e3 100644 --- a/tests/auto/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/qheaderview/tst_qheaderview.cpp @@ -192,6 +192,7 @@ private slots: void task248050_hideRow(); void QTBUG6058_reset(); void QTBUG7833_sectionClicked(); + void QTBUG8650_crashOnInsertSections(); protected: QHeaderView *view; @@ -2056,6 +2057,19 @@ void tst_QHeaderView::QTBUG7833_sectionClicked() QCOMPARE(pressedSpy.at(2).at(0).toInt(), 0); } +void tst_QHeaderView::QTBUG8650_crashOnInsertSections() +{ + QStringList headerLabels; + QHeaderView view(Qt::Horizontal); + QStandardItemModel model(2,2); + view.setModel(&model); + view.moveSection(1, 0); + view.hideSection(0); + + QList<QStandardItem *> items; + items << new QStandardItem("c"); + model.insertColumn(0, items); +} QTEST_MAIN(tst_QHeaderView) #include "tst_qheaderview.moc" diff --git a/tests/auto/qlistwidget/tst_qlistwidget.cpp b/tests/auto/qlistwidget/tst_qlistwidget.cpp index b3f1e1e..eb3fb6b 100644 --- a/tests/auto/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/qlistwidget/tst_qlistwidget.cpp @@ -132,6 +132,7 @@ private slots: void task199503_crashWhenCleared(); void task217070_scrollbarsAdjusted(); void task258949_keypressHangup(); + void QTBUG8086_currentItemChangedOnClick(); protected slots: @@ -1609,5 +1610,35 @@ void tst_QListWidget::task258949_keypressHangup() QCOMPARE(lw.currentIndex(), lw.model()->index(0,0)); } +void tst_QListWidget::QTBUG8086_currentItemChangedOnClick() +{ + qRegisterMetaType<QListWidgetItem*>("QListWidgetItem*"); + QWidget win; + QHBoxLayout layout(&win); + QListWidget list; + for (int i = 0 ; i < 4; ++i) + new QListWidgetItem(QString::number(i), &list); + + layout.addWidget(&list); + + QLineEdit edit; + layout.addWidget(&edit); + + edit.setFocus(); + win.show(); + + QSignalSpy spy(&list, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*))); + + QTest::qWaitForWindowShown(&win); + + QCOMPARE(spy.count(), 0); + + QTest::mouseClick(list.viewport(), Qt::LeftButton, 0, list.visualItemRect(list.item(2)).center()); + + QCOMPARE(spy.count(), 1); + +} + + QTEST_MAIN(tst_QListWidget) #include "tst_qlistwidget.moc" diff --git a/tests/auto/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp b/tests/auto/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp index a813110..99d775d 100644 --- a/tests/auto/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp +++ b/tests/auto/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp @@ -62,7 +62,7 @@ private slots: class DownloadCheckWidget : public QWidget { - Q_OBJECT; + Q_OBJECT public: DownloadCheckWidget(QWidget *parent = 0) : QWidget(parent) , progressDlg(this), netmanager(this) diff --git a/tests/auto/qnetworkconfigmanager/qnetworkconfigmanager.pro b/tests/auto/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro index 30eb5f0..e0028e5 100644 --- a/tests/auto/qnetworkconfigmanager/qnetworkconfigmanager.pro +++ b/tests/auto/qnetworkconfigurationmanager/qnetworkconfigurationmanager.pro @@ -1,5 +1,5 @@ load(qttest_p4) -SOURCES += tst_qnetworkconfigmanager.cpp +SOURCES += tst_qnetworkconfigurationmanager.cpp HEADERS += ../qbearertestcommon.h QT = core network diff --git a/tests/auto/qnetworkconfigmanager/tst_qnetworkconfigmanager.cpp b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp index 3052330..8b68006 100644 --- a/tests/auto/qnetworkconfigmanager/tst_qnetworkconfigmanager.cpp +++ b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp @@ -332,4 +332,4 @@ void tst_QNetworkConfigurationManager::configurationFromIdentifier() QTEST_MAIN(tst_QNetworkConfigurationManager) -#include "tst_qnetworkconfigmanager.moc" +#include "tst_qnetworkconfigurationmanager.moc" diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index cafeef0..e11900e 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -237,6 +237,8 @@ private Q_SLOTS: void lastModifiedHeaderForFile(); void lastModifiedHeaderForHttp(); + void httpCanReadLine(); + void rateControl_data(); void rateControl(); @@ -3315,6 +3317,21 @@ void tst_QNetworkReply::lastModifiedHeaderForHttp() QCOMPARE(header, realDate); } +void tst_QNetworkReply::httpCanReadLine() +{ + QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt")); + QNetworkReplyPtr reply = manager.get(request); + + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + QCOMPARE(reply->error(), QNetworkReply::NoError); + + QVERIFY(reply->canReadLine()); + QVERIFY(!reply->readAll().isEmpty()); + QVERIFY(!reply->canReadLine()); +} + void tst_QNetworkReply::rateControl_data() { QTest::addColumn<int>("rate"); @@ -3935,7 +3952,7 @@ void tst_QNetworkReply::httpReUsingConnectionSequential() } class HttpReUsingConnectionFromFinishedSlot : public QObject { - Q_OBJECT; + Q_OBJECT public: QNetworkReply* reply1; QNetworkReply* reply2; diff --git a/tests/auto/qscriptclass/tst_qscriptclass.cpp b/tests/auto/qscriptclass/tst_qscriptclass.cpp index 41c674c..aca33ce 100644 --- a/tests/auto/qscriptclass/tst_qscriptclass.cpp +++ b/tests/auto/qscriptclass/tst_qscriptclass.cpp @@ -688,6 +688,7 @@ void tst_QScriptClass::getAndSetProperty() QCOMPARE(obj1.propertyFlags(foo2), foo2Pflags); QVERIFY(cls.lastQueryPropertyObject().strictlyEquals(obj1)); QVERIFY(cls.lastQueryPropertyName() == foo2); + QEXPECT_FAIL("", "classObject.getOwnPropertyDescriptor() reads the property value", Continue); QVERIFY(!cls.lastPropertyObject().isValid()); QVERIFY(cls.lastPropertyFlagsObject().strictlyEquals(obj1)); QVERIFY(cls.lastPropertyFlagsName() == foo2); diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 8658240..d9beb45 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -155,6 +155,7 @@ private slots: void nativeFunctionScopes(); void evaluateProgram(); void collectGarbageAfterConnect(); + void promoteThisObjectToQObjectInConstructor(); void qRegExpInport_data(); void qRegExpInport(); @@ -4461,6 +4462,25 @@ void tst_QScriptEngine::collectGarbageAfterConnect() QVERIFY(widget == 0); } +static QScriptValue constructQObjectFromThisObject(QScriptContext *ctx, QScriptEngine *eng) +{ + Q_ASSERT(ctx->isCalledAsConstructor()); + return eng->newQObject(ctx->thisObject(), new QObject, QScriptEngine::ScriptOwnership); +} + +void tst_QScriptEngine::promoteThisObjectToQObjectInConstructor() +{ + QScriptEngine engine; + QScriptValue ctor = engine.newFunction(constructQObjectFromThisObject); + engine.globalObject().setProperty("Ctor", ctor); + QScriptValue object = engine.evaluate("new Ctor"); + QVERIFY(!object.isError()); + QVERIFY(object.isQObject()); + QVERIFY(object.toQObject() != 0); + QVERIFY(object.property("objectName").isString()); + QVERIFY(object.property("deleteLater").isFunction()); +} + static QRegExp minimal(QRegExp r) { r.setMinimal(true); return r; } void tst_QScriptEngine::qRegExpInport_data() diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp index ac9ca46..a0f10dd 100644 --- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp +++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp @@ -1245,6 +1245,7 @@ void tst_QScriptEngineAgent::positionChange_1() QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(1).lineNumber, lineNumber); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(1).columnNumber, 8); // 5 + 6 @@ -1279,6 +1280,7 @@ void tst_QScriptEngineAgent::positionChange_2() QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); QVERIFY(spy->at(1).scriptId != spy->at(0).scriptId); QCOMPARE(spy->at(1).lineNumber, lineNumber); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(1).columnNumber, 18); } @@ -1297,6 +1299,7 @@ void tst_QScriptEngineAgent::positionChange_2() QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(1).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(1).columnNumber, 11); } @@ -1327,12 +1330,14 @@ void tst_QScriptEngineAgent::positionChange_2() QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(1).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(1).columnNumber, 31); // void(i) QCOMPARE(spy->at(2).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(2).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(2).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(2).columnNumber, 31); } @@ -1351,18 +1356,21 @@ void tst_QScriptEngineAgent::positionChange_2() QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(1).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(1).columnNumber, 12); // ++i QCOMPARE(spy->at(2).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(2).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(2).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(2).columnNumber, 28); // ++i QCOMPARE(spy->at(3).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(3).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(3).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(3).columnNumber, 28); } @@ -1381,24 +1389,28 @@ void tst_QScriptEngineAgent::positionChange_2() QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(1).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(1).columnNumber, 12); // ++i QCOMPARE(spy->at(2).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(2).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(2).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(2).columnNumber, 17); // do QCOMPARE(spy->at(3).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(3).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(3).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(3).columnNumber, 12); // ++i QCOMPARE(spy->at(4).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(4).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(4).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(4).columnNumber, 17); } @@ -1429,6 +1441,7 @@ void tst_QScriptEngineAgent::positionChange_2() QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(1).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(1).columnNumber, 15); } @@ -1447,12 +1460,14 @@ void tst_QScriptEngineAgent::positionChange_2() QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(1).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(1).columnNumber, 32); // continue QCOMPARE(spy->at(2).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(2).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(2).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(2).columnNumber, 32); } @@ -1495,6 +1510,7 @@ void tst_QScriptEngineAgent::positionChange_2() QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(1).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(1).columnNumber, 31); } @@ -1513,12 +1529,14 @@ void tst_QScriptEngineAgent::positionChange_2() QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(1).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(1).columnNumber, 38); // break QCOMPARE(spy->at(2).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(2).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(2).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(2).columnNumber, 45); } @@ -1543,18 +1561,21 @@ void tst_QScriptEngineAgent::positionChange_2() QCOMPARE(spy->at(0).type, ScriptEngineEvent::PositionChange); QVERIFY(spy->at(0).scriptId != -1); QCOMPARE(spy->at(0).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(0).columnNumber, 7); // i = e QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(1).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(1).columnNumber, 29); // i = 2 QCOMPARE(spy->at(2).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(2).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(2).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(2).columnNumber, 48); } @@ -1567,12 +1588,14 @@ void tst_QScriptEngineAgent::positionChange_2() QCOMPARE(spy->at(0).type, ScriptEngineEvent::PositionChange); QVERIFY(spy->at(0).scriptId != -1); QCOMPARE(spy->at(0).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(0).columnNumber, 7); // i = 3 QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(1).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(1).columnNumber, 46); } @@ -1594,6 +1617,7 @@ void tst_QScriptEngineAgent::positionChange_2() QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(1).lineNumber, 1); + QEXPECT_FAIL("", "With JSC-based back-end, column number is always reported as 1", Continue); QCOMPARE(spy->at(1).columnNumber, 20); } delete spy; diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index f83cf58..5b79340 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -2047,7 +2047,9 @@ void tst_QScriptValue::getSetProperty() } // should still be deletable from C++ object.setProperty("undeletableProperty", QScriptValue()); + QEXPECT_FAIL("", "With JSC-based back-end, undeletable properties can't be deleted from C++", Continue); QVERIFY(!object.property("undeletableProperty").isValid()); + QEXPECT_FAIL("", "With JSC-based back-end, undeletable properties can't be deleted from C++", Continue); QCOMPARE(object.propertyFlags("undeletableProperty"), 0); // SkipInEnumeration @@ -2082,11 +2084,11 @@ void tst_QScriptValue::getSetProperty() object.setProperty("flagProperty", str, QScriptValue::ReadOnly); QCOMPARE(object.propertyFlags("flagProperty"), QScriptValue::ReadOnly); - object.setProperty("flagProperty", str, object.propertyFlags("flagProperty") | QScriptValue::Undeletable); - QCOMPARE(object.propertyFlags("flagProperty"), QScriptValue::ReadOnly | QScriptValue::Undeletable); + object.setProperty("flagProperty", str, object.propertyFlags("flagProperty") | QScriptValue::SkipInEnumeration); + QCOMPARE(object.propertyFlags("flagProperty"), QScriptValue::ReadOnly | QScriptValue::SkipInEnumeration); object.setProperty("flagProperty", str, QScriptValue::KeepExistingFlags); - QCOMPARE(object.propertyFlags("flagProperty"), QScriptValue::ReadOnly | QScriptValue::Undeletable); + QCOMPARE(object.propertyFlags("flagProperty"), QScriptValue::ReadOnly | QScriptValue::SkipInEnumeration); object.setProperty("flagProperty", str, QScriptValue::UserRange); QCOMPARE(object.propertyFlags("flagProperty"), QScriptValue::UserRange); diff --git a/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp b/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp index 5ca7a3d..55773f0 100644 --- a/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp +++ b/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp @@ -255,8 +255,14 @@ void tst_QScriptValueIterator::iterateArray() QVERIFY(it.value().strictlyEquals(array.property(propertyNames.at(i)))); QCOMPARE(it.value().toString(), propertyValues.at(i)); } - QCOMPARE(it.hasNext(), false); + QVERIFY(it.hasNext()); + it.next(); + QCOMPARE(it.name(), QString::fromLatin1("length")); + QVERIFY(it.value().isNumber()); + QCOMPARE(it.value().toInt32(), length); + QCOMPARE(it.flags(), QScriptValue::SkipInEnumeration | QScriptValue::Undeletable); + it.previous(); QCOMPARE(it.hasPrevious(), length > 0); for (int i = length - 1; i >= 0; --i) { it.previous(); @@ -301,7 +307,9 @@ void tst_QScriptValueIterator::iterateArray() QVERIFY(it.value().strictlyEquals(array.property(propertyNames.at(i)))); QCOMPARE(it.value().toString(), propertyValues.at(i)); } - QCOMPARE(it.hasNext(), false); + QCOMPARE(it.hasNext(), true); + it.next(); + QCOMPARE(it.name(), QString::fromLatin1("length")); } } @@ -420,9 +428,15 @@ void tst_QScriptValueIterator::iterateString() QCOMPARE(it.flags(), obj.propertyFlags(indexStr)); QCOMPARE(it.value().strictlyEquals(obj.property(indexStr)), true); } - QCOMPARE(it.hasNext(), false); + QVERIFY(it.hasNext()); + it.next(); + QCOMPARE(it.name(), QString::fromLatin1("length")); + QVERIFY(it.value().isNumber()); + QCOMPARE(it.value().toInt32(), length); + QCOMPARE(it.flags(), QScriptValue::ReadOnly | QScriptValue::SkipInEnumeration | QScriptValue::Undeletable); - QVERIFY(it.hasPrevious()); + it.previous(); + QCOMPARE(it.hasPrevious(), length > 0); for (int i = length - 1; i >= 0; --i) { it.previous(); QString indexStr = QScriptValue(&engine, i).toString(); diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 56eaf25..2339b21 100644 --- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -139,6 +139,8 @@ private slots: void taskQTBUG_7537_appearsAndSort(); void taskQTBUG_7716_unnecessaryDynamicSorting(); + void testMultipleProxiesWithSelection(); + protected: void buildHierarchy(const QStringList &data, QAbstractItemModel *model); void checkHierarchy(const QStringList &data, const QAbstractItemModel *model); @@ -2951,5 +2953,90 @@ void tst_QSortFilterProxyModel::taskQTBUG_7716_unnecessaryDynamicSorting() } } +class SelectionProxyModel : QAbstractProxyModel +{ + Q_OBJECT +public: + SelectionProxyModel() + : QAbstractProxyModel(), selectionModel(0) + { + } + + QModelIndex mapFromSource(QModelIndex const&) const + { return QModelIndex(); } + + QModelIndex mapToSource(QModelIndex const&) const + { return QModelIndex(); } + + QModelIndex index(int, int, const QModelIndex&) const + { return QModelIndex(); } + + QModelIndex parent(const QModelIndex&) const + { return QModelIndex(); } + + int rowCount(const QModelIndex&) const + { return 0; } + + int columnCount(const QModelIndex&) const + { return 0; } + + void setSourceModel( QAbstractItemModel *sourceModel ) + { + beginResetModel(); + disconnect( sourceModel, SIGNAL(modelAboutToBeReset()), this, SLOT(sourceModelAboutToBeReset()) ); + QAbstractProxyModel::setSourceModel( sourceModel ); + connect( sourceModel, SIGNAL(modelAboutToBeReset()), this, SLOT(sourceModelAboutToBeReset()) ); + endResetModel(); + } + + void setSelectionModel( QItemSelectionModel *_selectionModel ) + { + selectionModel = _selectionModel; + } + +private slots: + void sourceModelAboutToBeReset() + { + QVERIFY( selectionModel->selectedIndexes().size() == 1 ); + beginResetModel(); + } + + void sourceModelReset() + { + endResetModel(); + } + +private: + QItemSelectionModel *selectionModel; + +}; + +void tst_QSortFilterProxyModel::testMultipleProxiesWithSelection() +{ + QStringListModel model; + const QStringList initial = QString("bravo charlie delta echo").split(" "); + model.setStringList(initial); + + QSortFilterProxyModel proxy; + proxy.setSourceModel( &model ); + + SelectionProxyModel proxy1; + QSortFilterProxyModel proxy2; + + // Note that the order here matters. The order of the sourceAboutToBeReset + // exposes the bug in QSortFilterProxyModel. + proxy2.setSourceModel( &proxy ); + proxy1.setSourceModel( &proxy ); + + QItemSelectionModel selectionModel(&proxy2); + proxy1.setSelectionModel( &selectionModel ); + + selectionModel.select( proxy2.index( 0, 0 ), QItemSelectionModel::Select ); + + // trick the proxy into emitting begin/end reset signals. + proxy.setSourceModel(0); + +} + QTEST_MAIN(tst_QSortFilterProxyModel) #include "tst_qsortfilterproxymodel.moc" diff --git a/tests/auto/qsqldatabase/tst_databases.h b/tests/auto/qsqldatabase/tst_databases.h index 4e99f18..5837719 100644 --- a/tests/auto/qsqldatabase/tst_databases.h +++ b/tests/auto/qsqldatabase/tst_databases.h @@ -95,12 +95,14 @@ static QString qGetHostName() // to prevent nameclashes on our database server, each machine // will use its own set of table names. Call this function to get // "tablename_hostname" -inline static QString qTableName( const QString& prefix, QSqlDriver* driver = 0 ) +inline static QString qTableName( const QString& prefix, const char *sourceFileName ) { - if ( !driver ) - return prefix + "_" + qGetHostName().replace( "-", "_" ); - else - return driver->escapeIdentifier( prefix + "_" + qGetHostName(), QSqlDriver::TableName ); + return QLatin1String("dbtst")+QString::number(qHash(QLatin1String(sourceFileName) + "_" + qGetHostName().replace( "-", "_" )), 16)+"_"+prefix; +} + +inline static QString qTableName( const QString& prefix, QSqlDriver* driver ) +{ + return driver->escapeIdentifier( prefix + "_" + qGetHostName(), QSqlDriver::TableName ); } inline static bool testWhiteSpaceNames( const QString &name ) @@ -250,8 +252,8 @@ public: // addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=iceblink.nokia.troll.no\\ICEBLINK", "troll", "trond", "" ); // addDb( "QODBC3", "DRIVER={SQL Native Client};SERVER=silence.nokia.troll.no\\SQLEXPRESS", "troll", "trond", "" ); -// addDb( "QODBC", "DRIVER={MySQL ODBC 5.1 Driver};SERVER=mysql5-nokia.trolltech.com.au;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); -// addDb( "QODBC", "DRIVER={MySQL ODBC 5.1 Driver};SERVER=mysql4-nokia.trolltech.com.au;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); +// addDb( "QODBC", "DRIVER={MySQL ODBC 5.1 Driver};SERVER=bq-mysql50.apac.nokia.com;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); +// addDb( "QODBC", "DRIVER={MySQL ODBC 5.1 Driver};SERVER=bq-mysql51.apac.nokia.com;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); // addDb( "QODBC", "DRIVER={FreeTDS};SERVER=horsehead.nokia.troll.no;DATABASE=testdb;PORT=4101;UID=troll;PWD=trondk", "troll", "trondk", "" ); // addDb( "QODBC", "DRIVER={FreeTDS};SERVER=silence.nokia.troll.no;DATABASE=testdb;PORT=2392;UID=troll;PWD=trond", "troll", "trond", "" ); // addDb( "QODBC", "DRIVER={FreeTDS};SERVER=bq-winserv2003-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433;UID=testuser;PWD=Ee4Gabf6_;TDS_Version=8.0", "", "", "" ); @@ -261,7 +263,7 @@ public: // addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=bq-winserv2003-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433", "testuser", "Ee4Gabf6_", "" ); // addDb( "QODBC3", "DRIVER={SQL SERVER};SERVER=bq-winserv2008-x86-01.apac.nokia.com;DATABASE=testdb;PORT=1433", "testuser", "Ee4Gabf6_", "" ); // addDb( "QODBC", "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\dbs\\access\\testdb.mdb", "", "", "" ); -// addDb( "QODBC", "DRIVER={Postgresql};SERVER=postgres81-nokia.trolltech.com.au;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); +// addDb( "QODBC", "DRIVER={Postgresql};SERVER=bq-pgsql84.apac.nokia.com;DATABASE=testdb", "testuser", "Ee4Gabf6_", "" ); } void open() @@ -338,7 +340,7 @@ public: foreach(const QString &table2, dbtables.filter(table, Qt::CaseInsensitive)) { if(table2.compare(table.section('.', -1, -1), Qt::CaseInsensitive) == 0) { table=db.driver()->escapeIdentifier(table2, QSqlDriver::TableName); - if(db.driverName().startsWith( "QPSQL" )) + if(isPostgreSQL(db)) wasDropped = q.exec( "drop table " + table + " cascade"); else wasDropped = q.exec( "drop table " + table); @@ -483,16 +485,16 @@ public: static bool isPostgreSQL( QSqlDatabase db ) { - return db.driverName().startsWith("QPSQL") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("PostgreSQL") ); + return db.driverName().startsWith("QPSQL") || (db.driverName().startsWith("QODBC") && ( db.databaseName().contains("PostgreSQL", Qt::CaseInsensitive) || db.databaseName().contains("pgsql", Qt::CaseInsensitive) ) ); } static bool isMySQL( QSqlDatabase db ) { - return db.driverName().startsWith("QMYSQL") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("MySQL") ); + return db.driverName().startsWith("QMYSQL") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("MySQL", Qt::CaseInsensitive) ); } static bool isDB2( QSqlDatabase db ) { - return db.driverName().startsWith("QDB2") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("db2") ); + return db.driverName().startsWith("QDB2") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("db2", Qt::CaseInsensitive) ); } // -1 on fail, else Oracle version diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index fe084fa..b2b592b 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -259,10 +259,10 @@ struct FieldDef { // excluding the primary key field static int createFieldTable(const FieldDef fieldDefs[], QSqlDatabase db) { - tst_Databases::safeDropTable(db, qTableName("qtestfields")); + tst_Databases::safeDropTable(db, qTableName("qtestfields", __FILE__)); QSqlQuery q(db); // construct a create table statement consisting of all fieldtypes - QString qs = "create table " + qTableName("qtestfields"); + QString qs = "create table " + qTableName("qtestfields", __FILE__); QString autoName = tst_Databases::autoFieldName(db); if (tst_Databases::isMSAccess(db)) qs.append(" (id int not null"); @@ -316,18 +316,18 @@ void tst_QSqlDatabase::createTestTables(QSqlDatabase db) // please never ever change this table; otherwise fix all tests ;) if (tst_Databases::isMSAccess(db)) { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest") + + QVERIFY_SQL(q, exec("create table " + qTableName("qtest", __FILE__) + " (id int not null, t_varchar varchar(40) not null, t_char char(40), " "t_numeric number, primary key (id, t_varchar))")); } else { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest") + + QVERIFY_SQL(q, exec("create table " + qTableName("qtest", __FILE__) + " (id integer not null, t_varchar varchar(40) not null, " "t_char char(40), t_numeric numeric(6, 3), primary key (id, t_varchar))")); } if (testWhiteSpaceNames(db.driverName())) { QString qry = "create table " - + db.driver()->escapeIdentifier(qTableName("qtest") + " test", QSqlDriver::TableName) + + db.driver()->escapeIdentifier(qTableName("qtest", __FILE__) + " test", QSqlDriver::TableName) + '(' + db.driver()->escapeIdentifier(QLatin1String("test test"), QSqlDriver::FieldName) + " int not null primary key)"; @@ -346,45 +346,45 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db) } // drop the view first, otherwise we'll get dependency problems - tst_Databases::safeDropViews(db, QStringList() << qTableName("qtest_view") << qTableName("qtest_view2")); + tst_Databases::safeDropViews(db, QStringList() << qTableName("qtest_view", __FILE__) << qTableName("qtest_view2", __FILE__)); QStringList tableNames; - tableNames << qTableName("qtest") - << qTableName("qtestfields") - << qTableName("qtestalter") - << qTableName("qtest_temp") - << qTableName("qtest_bigint") - << qTableName("qtest_xmltype") - << qTableName("latin1table") - << qTableName("qtest_sqlguid") - << qTableName("batable") - << qTableName("qtest_prec") - << qTableName("uint") - << qTableName("strings") - << qTableName("numericfields") - << qTableName("qtest_ibaseblobs") - << qTableName("qtestBindBool") - << qTableName("testqGetString") - << qTableName("qtest_sqlguid") - << qTableName("uint_table") - << qTableName("uint_test") - << qTableName("bug_249059"); + tableNames << qTableName("qtest", __FILE__) + << qTableName("qtestfields", __FILE__) + << qTableName("qtestalter", __FILE__) + << qTableName("qtest_temp", __FILE__) + << qTableName("qtest_bigint", __FILE__) + << qTableName("qtest_xmltype", __FILE__) + << qTableName("latin1table", __FILE__) + << qTableName("qtest_sqlguid", __FILE__) + << qTableName("batable", __FILE__) + << qTableName("qtest_prec", __FILE__) + << qTableName("uint", __FILE__) + << qTableName("strings", __FILE__) + << qTableName("numericfields", __FILE__) + << qTableName("qtest_ibaseblobs", __FILE__) + << qTableName("qtestBindBool", __FILE__) + << qTableName("testqGetString", __FILE__) + << qTableName("qtest_sqlguid", __FILE__) + << qTableName("uint_table", __FILE__) + << qTableName("uint_test", __FILE__) + << qTableName("bug_249059", __FILE__); QSqlQuery q(0, db); if (db.driverName().startsWith("QPSQL")) { - q.exec("drop schema " + qTableName("qtestschema") + " cascade"); - q.exec("drop schema " + qTableName("qtestScHeMa") + " cascade"); + q.exec("drop schema " + qTableName("qtestschema", __FILE__) + " cascade"); + q.exec("drop schema " + qTableName("qtestScHeMa", __FILE__) + " cascade"); } if (testWhiteSpaceNames(db.driverName())) - tableNames << db.driver()->escapeIdentifier(qTableName("qtest") + " test", QSqlDriver::TableName); + tableNames << db.driver()->escapeIdentifier(qTableName("qtest", __FILE__) + " test", QSqlDriver::TableName); tst_Databases::safeDropTables(db, tableNames); if (db.driverName().startsWith("QOCI")) { - q.exec("drop user "+qTableName("CREATOR")+" cascade"); - q.exec("drop user "+qTableName("APPUSER")+" cascade"); - q.exec("DROP TABLE system."+qTableName("mypassword")); + q.exec("drop user "+qTableName("CREATOR", __FILE__)+" cascade"); + q.exec("drop user "+qTableName("APPUSER", __FILE__)+" cascade"); + q.exec("DROP TABLE system."+qTableName("mypassword", __FILE__)); } } @@ -394,13 +394,14 @@ void tst_QSqlDatabase::populateTestTables(QSqlDatabase db) if (!db.isValid()) return; QSqlQuery q(db); + const QString qtest(qTableName("qtest", __FILE__)); - q.exec("delete from " + qTableName("qtest")); //non-fatal - QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " (id, t_varchar, t_char, t_numeric) values (0, 'VarChar0', 'Char0', 1.1)")); - QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " (id, t_varchar, t_char, t_numeric) values (1, 'VarChar1', 'Char1', 2.2)")); - QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " (id, t_varchar, t_char, t_numeric) values (2, 'VarChar2', 'Char2', 3.3)")); - QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " (id, t_varchar, t_char, t_numeric) values (3, 'VarChar3', 'Char3', 4.4)")); - QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " (id, t_varchar, t_char, t_numeric) values (4, 'VarChar4', NULL, NULL)")); + q.exec("delete from " + qtest); //non-fatal + QVERIFY_SQL(q, exec("insert into " + qtest + " (id, t_varchar, t_char, t_numeric) values (0, 'VarChar0', 'Char0', 1.1)")); + QVERIFY_SQL(q, exec("insert into " + qtest + " (id, t_varchar, t_char, t_numeric) values (1, 'VarChar1', 'Char1', 2.2)")); + QVERIFY_SQL(q, exec("insert into " + qtest + " (id, t_varchar, t_char, t_numeric) values (2, 'VarChar2', 'Char2', 3.3)")); + QVERIFY_SQL(q, exec("insert into " + qtest + " (id, t_varchar, t_char, t_numeric) values (3, 'VarChar3', 'Char3', 4.4)")); + QVERIFY_SQL(q, exec("insert into " + qtest + " (id, t_varchar, t_char, t_numeric) values (4, 'VarChar4', NULL, NULL)")); } void tst_QSqlDatabase::initTestCase() @@ -496,7 +497,7 @@ void tst_QSqlDatabase::recordNonSelect() Q3SqlRecordInfo rInf = db.recordInfo(q); QVERIFY(rInf.isEmpty()); - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_temp") + " (id int)")); + QVERIFY_SQL(q, exec("create table " + qTableName("qtest_temp", __FILE__) + " (id int)")); // query without result set should return empty record rec = db.record(q); @@ -512,6 +513,8 @@ void tst_QSqlDatabase::tables() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); + const QString qtest(qTableName("qtest", __FILE__)), qtest_view(qTableName("qtest_view", __FILE__)), temp_tab(qTableName("test_tab", __FILE__)); + bool views = true; bool tempTables = false; @@ -520,50 +523,50 @@ void tst_QSqlDatabase::tables() QSKIP( "Test requires MySQL >= 5.0", SkipSingle ); - if (!q.exec("CREATE VIEW " + qTableName("qtest_view") + " as select * from " + qTableName("qtest"))) { + if (!q.exec("CREATE VIEW " + qtest_view + " as select * from " + qtest)) { qDebug(QString("DBMS '%1' cannot handle VIEWs: %2").arg( tst_Databases::dbToString(db)).arg(QString(tst_Databases::printError(q.lastError()))).toLatin1()); views = false; } if (db.driverName().startsWith("QSQLITE3")) { - QVERIFY_SQL(q, exec("CREATE TEMPORARY TABLE " + qTableName("temp_tab") + " (id int)")); + QVERIFY_SQL(q, exec("CREATE TEMPORARY TABLE " + temp_tab + " (id int)")); tempTables = true; } QStringList tables = db.tables(QSql::Tables); - QVERIFY(tables.contains(qTableName("qtest"), Qt::CaseInsensitive)); + QVERIFY(tables.contains(qtest, Qt::CaseInsensitive)); QVERIFY(!tables.contains("sql_features", Qt::CaseInsensitive)); //check for postgres 7.4 internal tables if (views) { - QVERIFY(!tables.contains(qTableName("qtest_view"), Qt::CaseInsensitive)); + QVERIFY(!tables.contains(qtest_view, Qt::CaseInsensitive)); } if (tempTables) - QVERIFY(tables.contains(qTableName("temp_tab"), Qt::CaseInsensitive)); + QVERIFY(tables.contains(temp_tab, Qt::CaseInsensitive)); tables = db.tables(QSql::Views); if (views) { - if(!tables.contains(qTableName("qtest_view"), Qt::CaseInsensitive)) - qDebug() << "failed to find" << qTableName("qtest_view") << "in" << tables; - QVERIFY(tables.contains(qTableName("qtest_view"), Qt::CaseInsensitive)); + if(!tables.contains(qtest_view, Qt::CaseInsensitive)) + qDebug() << "failed to find" << qtest_view << "in" << tables; + QVERIFY(tables.contains(qtest_view, Qt::CaseInsensitive)); } if (tempTables) - QVERIFY(!tables.contains(qTableName("temp_tab"), Qt::CaseInsensitive)); - QVERIFY(!tables.contains(qTableName("qtest"), Qt::CaseInsensitive)); + QVERIFY(!tables.contains(temp_tab, Qt::CaseInsensitive)); + QVERIFY(!tables.contains(qtest, Qt::CaseInsensitive)); tables = db.tables(QSql::SystemTables); - QVERIFY(!tables.contains(qTableName("qtest"), Qt::CaseInsensitive)); - QVERIFY(!tables.contains(qTableName("qtest_view"), Qt::CaseInsensitive)); - QVERIFY(!tables.contains(qTableName("temp_tab"), Qt::CaseInsensitive)); + QVERIFY(!tables.contains(qtest, Qt::CaseInsensitive)); + QVERIFY(!tables.contains(qtest_view, Qt::CaseInsensitive)); + QVERIFY(!tables.contains(temp_tab, Qt::CaseInsensitive)); tables = db.tables(QSql::AllTables); if (views) - QVERIFY(tables.contains(qTableName("qtest_view"), Qt::CaseInsensitive)); + QVERIFY(tables.contains(qtest_view, Qt::CaseInsensitive)); if (tempTables) - QVERIFY(tables.contains(qTableName("temp_tab"), Qt::CaseInsensitive)); - QVERIFY(tables.contains(qTableName("qtest"), Qt::CaseInsensitive)); + QVERIFY(tables.contains(temp_tab, Qt::CaseInsensitive)); + QVERIFY(tables.contains(qtest, Qt::CaseInsensitive)); if (db.driverName().startsWith("QPSQL")) { - QVERIFY(tables.contains(qTableName("qtest") + " test")); + QVERIFY(tables.contains(qtest + " test")); } } @@ -574,7 +577,7 @@ void tst_QSqlDatabase::whitespaceInIdentifiers() CHECK_DATABASE(db); if (testWhiteSpaceNames(db.driverName())) { - QString tableName = qTableName("qtest") + " test"; + const QString tableName(qTableName("qtest", __FILE__) + " test"); QVERIFY(db.tables().contains(tableName, Qt::CaseInsensitive)); QSqlRecord rec = db.record(db.driver()->escapeIdentifier(tableName, QSqlDriver::TableName)); @@ -602,14 +605,15 @@ void tst_QSqlDatabase::alterTable() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); + const QString qtestalter(qTableName("qtestalter", __FILE__)); QSqlQuery q(db); - QVERIFY_SQL(q, exec("create table " + qTableName("qtestalter") + " (F1 char(20), F2 char(20), F3 char(20))")); - QSqlRecord rec = db.record(qTableName("qtestalter")); + QVERIFY_SQL(q, exec("create table " + qtestalter + " (F1 char(20), F2 char(20), F3 char(20))")); + QSqlRecord rec = db.record(qtestalter); QCOMPARE((int)rec.count(), 3); #ifdef QT3_SUPPORT - Q3SqlRecordInfo rinf = db.recordInfo(qTableName("qtestalter")); + Q3SqlRecordInfo rinf = db.recordInfo(qtestalter); QCOMPARE((int)rinf.count(), 3); #endif @@ -622,13 +626,13 @@ void tst_QSqlDatabase::alterTable() #endif } - if (!q.exec("alter table " + qTableName("qtestalter") + " drop column F2")) { + if (!q.exec("alter table " + qtestalter + " drop column F2")) { QSKIP("DBMS doesn't support dropping columns in ALTER TABLE statement", SkipSingle); } - rec = db.record(qTableName("qtestalter")); + rec = db.record(qtestalter); #ifdef QT3_SUPPORT - rinf = db.recordInfo(qTableName("qtestalter")); + rinf = db.recordInfo(qtestalter); #endif QCOMPARE((int)rec.count(), 2); @@ -643,7 +647,7 @@ void tst_QSqlDatabase::alterTable() QCOMPARE(rinf[ 1 ].name().upper(), QString("F3")); #endif - q.exec("select * from " + qTableName("qtestalter")); + q.exec("select * from " + qtestalter); #ifdef QT3_SUPPORT rec = db.record(q); @@ -730,17 +734,17 @@ void tst_QSqlDatabase::commonFieldTest(const FieldDef fieldDefs[], QSqlDatabase // check whether recordInfo returns the right types #ifdef QT3_SUPPORT - Q3SqlRecordInfo inf = db.recordInfo(qTableName("qtestfields")); + Q3SqlRecordInfo inf = db.recordInfo(qTableName("qtestfields", __FILE__)); QCOMPARE((int)inf.count(), fieldCount+1); testRecordInfo(fieldDefs, inf); #endif - QSqlRecord rec = db.record(qTableName("qtestfields")); + QSqlRecord rec = db.record(qTableName("qtestfields", __FILE__)); QCOMPARE((int)rec.count(), fieldCount+1); testRecord(fieldDefs, rec, db); QSqlQuery q(db); - QVERIFY_SQL(q, exec("select * from " + qTableName("qtestfields"))); + QVERIFY_SQL(q, exec("select * from " + qTableName("qtestfields", __FILE__))); #ifdef QT3_SUPPORT inf = db.recordInfo(q); @@ -760,7 +764,7 @@ void tst_QSqlDatabase::checkValues(const FieldDef fieldDefs[], QSqlDatabase db) #ifdef QT3_SUPPORT CHECK_DATABASE(db); - Q3SqlCursor cur(qTableName("qtestfields"), true, db); + Q3SqlCursor cur(qTableName("qtestfields", __FILE__), true, db); QVERIFY_SQL(cur, select()); QSqlRecord* rec = cur.primeInsert(); Q_ASSERT(rec); @@ -821,7 +825,7 @@ void tst_QSqlDatabase::checkNullValues(const FieldDef fieldDefs[], QSqlDatabase #ifdef QT3_SUPPORT CHECK_DATABASE(db); - Q3SqlCursor cur(qTableName("qtestfields"), true, db); + Q3SqlCursor cur(qTableName("qtestfields", __FILE__), true, db); QVERIFY_SQL(cur, select()); QSqlRecord* rec = cur.primeInsert(); Q_ASSERT(rec); @@ -955,12 +959,12 @@ void tst_QSqlDatabase::recordOCI() checkValues(fieldDefs, db); // some additional tests - QSqlRecord rec = db.record(qTableName("qtestfields")); + QSqlRecord rec = db.record(qTableName("qtestfields", __FILE__)); QCOMPARE(rec.field("T_NUMBER").length(), 10); QCOMPARE(rec.field("T_NUMBER").precision(), 5); QSqlQuery q(db); - QVERIFY_SQL(q, exec("SELECT * FROM " + qTableName("qtestfields"))); + QVERIFY_SQL(q, exec("SELECT * FROM " + qTableName("qtestfields", __FILE__))); rec = q.record(); QCOMPARE(rec.field("T_NUMBER").length(), 10); QCOMPARE(rec.field("T_NUMBER").precision(), 5); @@ -1024,11 +1028,11 @@ void tst_QSqlDatabase::recordPSQL() if(tst_Databases::isPostgreSQL(db)) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); - q.exec("drop sequence " + qTableName("qtestfields") + "_t_bigserial_seq"); - q.exec("drop sequence " + qTableName("qtestfields") + "_t_serial_seq"); + q.exec("drop sequence " + qTableName("qtestfields", __FILE__) + "_t_bigserial_seq"); + q.exec("drop sequence " + qTableName("qtestfields", __FILE__) + "_t_serial_seq"); // older psql cut off the table name - q.exec("drop sequence " + qTableName("qtestfields").left(15) + "_t_bigserial_seq"); - q.exec("drop sequence " + qTableName("qtestfields").left(18) + "_t_serial_seq"); + q.exec("drop sequence " + qTableName("qtestfields", __FILE__).left(15) + "_t_bigserial_seq"); + q.exec("drop sequence " + qTableName("qtestfields", __FILE__).left(18) + "_t_serial_seq"); const int fieldCount = createFieldTable(fieldDefs, db); QVERIFY(fieldCount > 0); @@ -1325,6 +1329,7 @@ void tst_QSqlDatabase::transaction() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); + const QString qtest(qTableName("qtest", __FILE__)); if (!db.driver()->hasFeature(QSqlDriver::Transactions)) { QSKIP("DBMS not transaction capable", SkipSingle); @@ -1333,8 +1338,8 @@ void tst_QSqlDatabase::transaction() QVERIFY(db.transaction()); QSqlQuery q(db); - QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " values (40, 'VarChar40', 'Char40', 40.40)")); - QVERIFY_SQL(q, exec("select * from " + qTableName("qtest") + " where id = 40")); + QVERIFY_SQL(q, exec("insert into " + qtest + " values (40, 'VarChar40', 'Char40', 40.40)")); + QVERIFY_SQL(q, exec("select * from " + qtest + " where id = 40")); QVERIFY(q.next()); QCOMPARE(q.value(0).toInt(), 40); q.clear(); @@ -1342,15 +1347,15 @@ void tst_QSqlDatabase::transaction() QVERIFY(db.commit()); QVERIFY(db.transaction()); - QVERIFY_SQL(q, exec("select * from " + qTableName("qtest") + " where id = 40")); + QVERIFY_SQL(q, exec("select * from " + qtest + " where id = 40")); QVERIFY(q.next()); QCOMPARE(q.value(0).toInt(), 40); q.clear(); QVERIFY(db.commit()); QVERIFY(db.transaction()); - QVERIFY_SQL(q, exec("insert into " + qTableName("qtest") + " values (41, 'VarChar41', 'Char41', 41.41)")); - QVERIFY_SQL(q, exec("select * from " + qTableName("qtest") + " where id = 41")); + QVERIFY_SQL(q, exec("insert into " + qtest + " values (41, 'VarChar41', 'Char41', 41.41)")); + QVERIFY_SQL(q, exec("select * from " + qtest + " where id = 41")); QVERIFY(q.next()); QCOMPARE(q.value(0).toInt(), 41); q.clear(); // for SQLite which does not allow any references on rows that shall be rolled back @@ -1363,7 +1368,7 @@ void tst_QSqlDatabase::transaction() } } - QVERIFY_SQL(q, exec("select * from " + qTableName("qtest") + " where id = 41")); + QVERIFY_SQL(q, exec("select * from " + qtest + " where id = 41")); if(db.driverName().startsWith("QODBC") && dbName.contains("MySQL")) QEXPECT_FAIL("", "Some odbc drivers don't actually roll back despite telling us they do, especially the mysql driver", Continue); QVERIFY(!q.next()); @@ -1377,6 +1382,7 @@ void tst_QSqlDatabase::bigIntField() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); QString drvName = db.driverName(); + const QString qtest_bigint(qTableName("qtest_bigint", __FILE__)); QSqlQuery q(db); q.setForwardOnly(true); @@ -1384,19 +1390,19 @@ void tst_QSqlDatabase::bigIntField() q.setNumericalPrecisionPolicy(QSql::LowPrecisionInt64); if (drvName.startsWith("QMYSQL")) { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_bigint") + " (id int, t_s64bit bigint, t_u64bit bigint unsigned)")); + QVERIFY_SQL(q, exec("create table " + qtest_bigint + " (id int, t_s64bit bigint, t_u64bit bigint unsigned)")); } else if (drvName.startsWith("QPSQL") || drvName.startsWith("QDB2") || tst_Databases::isSqlServer(db)) { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_bigint") + "(id int, t_s64bit bigint, t_u64bit bigint)")); + QVERIFY_SQL(q, exec("create table " + qtest_bigint + "(id int, t_s64bit bigint, t_u64bit bigint)")); } else if (drvName.startsWith("QOCI")) { - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_bigint") + " (id int, t_s64bit int, t_u64bit int)")); + QVERIFY_SQL(q, exec("create table " + qtest_bigint + " (id int, t_s64bit int, t_u64bit int)")); //} else if (drvName.startsWith("QIBASE")) { - // QVERIFY_SQL(q, exec("create table " + qTableName("qtest_bigint") + " (id int, t_s64bit int64, t_u64bit int64)")); + // QVERIFY_SQL(q, exec("create table " + qtest_bigint + " (id int, t_s64bit int64, t_u64bit int64)")); } else { QSKIP("no 64 bit integer support", SkipAll); } - QVERIFY(q.prepare("insert into " + qTableName("qtest_bigint") + " values (?, ?, ?)")); + QVERIFY(q.prepare("insert into " + qtest_bigint + " values (?, ?, ?)")); qlonglong ll = Q_INT64_C(9223372036854775807); qulonglong ull = Q_UINT64_C(18446744073709551615); @@ -1420,7 +1426,7 @@ void tst_QSqlDatabase::bigIntField() q.bindValue(2, (qlonglong) ull); QVERIFY_SQL(q, exec()); } - QVERIFY(q.exec("select * from " + qTableName("qtest_bigint") + " order by id")); + QVERIFY(q.exec("select * from " + qtest_bigint + " order by id")); QVERIFY(q.next()); QCOMPARE(q.value(1).toDouble(), (double)ll); QCOMPARE(q.value(1).toLongLong(), ll); @@ -1447,32 +1453,32 @@ void tst_QSqlDatabase::caseSensivity() || db.driverName().startsWith("QODBC")) cs = true; - QSqlRecord rec = db.record(qTableName("qtest")); + QSqlRecord rec = db.record(qTableName("qtest", __FILE__)); QVERIFY((int)rec.count() > 0); if (!cs) { - rec = db.record(qTableName("QTEST").toUpper()); + rec = db.record(qTableName("QTEST", __FILE__).toUpper()); QVERIFY((int)rec.count() > 0); - rec = db.record(qTableName("qTesT")); + rec = db.record(qTableName("qTesT", __FILE__)); QVERIFY((int)rec.count() > 0); } #ifdef QT3_SUPPORT - Q3SqlRecordInfo rInf = db.recordInfo(qTableName("qtest")); + Q3SqlRecordInfo rInf = db.recordInfo(qTableName("qtest", __FILE__)); QVERIFY((int)rInf.count() > 0); if (!cs) { - rInf = db.recordInfo(qTableName("QTEST").upper()); + rInf = db.recordInfo(qTableName("QTEST", __FILE__).upper()); QVERIFY((int)rInf.count() > 0); - rInf = db.recordInfo(qTableName("qTesT")); + rInf = db.recordInfo(qTableName("qTesT", __FILE__)); QVERIFY((int)rInf.count() > 0); } #endif - rec = db.primaryIndex(qTableName("qtest")); + rec = db.primaryIndex(qTableName("qtest", __FILE__)); QVERIFY((int)rec.count() > 0); if (!cs) { - rec = db.primaryIndex(qTableName("QTEST").toUpper()); + rec = db.primaryIndex(qTableName("QTEST", __FILE__).toUpper()); QVERIFY((int)rec.count() > 0); - rec = db.primaryIndex(qTableName("qTesT")); + rec = db.primaryIndex(qTableName("qTesT", __FILE__)); QVERIFY((int)rec.count() > 0); } } @@ -1488,7 +1494,7 @@ void tst_QSqlDatabase::noEscapedFieldNamesInRecord() fieldname = fieldname.toUpper(); QSqlQuery q(db); - QString query = "SELECT " + db.driver()->escapeIdentifier(fieldname, QSqlDriver::FieldName) + " FROM " + qTableName("qtest"); + QString query = "SELECT " + db.driver()->escapeIdentifier(fieldname, QSqlDriver::FieldName) + " FROM " + qTableName("qtest", __FILE__); QVERIFY_SQL(q, exec(query)); QCOMPARE(q.record().fieldName(0), fieldname); } @@ -1508,9 +1514,9 @@ void tst_QSqlDatabase::psql_schemas() QVERIFY_SQL( q, exec("set client_min_messages='warning'")); } - QVERIFY_SQL(q, exec("CREATE SCHEMA " + qTableName("qtestschema"))); + QVERIFY_SQL(q, exec("CREATE SCHEMA " + qTableName("qtestschema", __FILE__))); - QString table = qTableName("qtestschema") + '.' + qTableName("qtesttable"); + QString table = qTableName("qtestschema", __FILE__) + '.' + qTableName("qtesttable", __FILE__); QVERIFY_SQL(q, exec("CREATE TABLE " + table + " (id int primary key, name varchar(20))")); QVERIFY(db.tables().contains(table)); @@ -1546,10 +1552,10 @@ void tst_QSqlDatabase::psql_escapedIdentifiers() if(tst_Databases::isPostgreSQL(db)) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); - QString schemaName = qTableName("qtestScHeMa"); - QString tableName = qTableName("qtest"); - QString field1Name = QString("fIeLdNaMe"); - QString field2Name = QString("ZuLu"); + const QString schemaName(qTableName("qtestScHeMa", __FILE__)), + tableName(qTableName("qtest", __FILE__)), + field1Name(QLatin1String("fIeLdNaMe")), + field2Name(QLatin1String("ZuLu")); q.exec(QString("DROP SCHEMA \"%1\" CASCADE").arg(schemaName)); QString createSchema = QString("CREATE SCHEMA \"%1\"").arg(schemaName); @@ -1576,7 +1582,6 @@ void tst_QSqlDatabase::psql_escapedIdentifiers() q.exec(QString("DROP SCHEMA \"%1\" CASCADE").arg(schemaName)); } - void tst_QSqlDatabase::psql_escapeBytea() { QFETCH(QString, dbName); @@ -1587,7 +1592,7 @@ void tst_QSqlDatabase::psql_escapeBytea() QByteArray ba(dta, 4); QSqlQuery q(db); - QString tableName = qTableName("batable"); + const QString tableName(qTableName("batable", __FILE__)); QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (ba bytea)").arg(tableName))); QSqlQuery iq(db); @@ -1620,7 +1625,7 @@ void tst_QSqlDatabase::bug_249059() QSKIP("Test requires PostgreSQL >= 7.3", SkipSingle); QSqlQuery q(db); - QString tableName = qTableName("bug_249059"); + const QString tableName(qTableName("bug_249059", __FILE__)); QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (dt timestamp, t time)").arg(tableName))); QSqlQuery iq(db); @@ -1655,7 +1660,7 @@ void tst_QSqlDatabase::precisionPolicy() // DBMS_SPECIFIC(db, "QPSQL"); QSqlQuery q(db); - QString tableName = qTableName("qtest_prec"); + const QString tableName(qTableName("qtest_prec", __FILE__)); if(!db.driver()->hasFeature(QSqlDriver::LowPrecisionNumbers)) QSKIP("Driver or database doesn't support setting precision policy", SkipSingle); @@ -1752,7 +1757,7 @@ void tst_QSqlDatabase::mysqlOdbc_unsignedIntegers() } QSqlQuery q(db); - QString tableName = qTableName("uint"); + const QString tableName(qTableName("uint", __FILE__)); QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (foo integer(10) unsigned, bar integer(10))").arg(tableName))); QVERIFY_SQL(q, exec(QString("INSERT INTO %1 VALUES (-4000000000, -4000000000)").arg(tableName))); QVERIFY_SQL(q, exec(QString("INSERT INTO %1 VALUES (4000000000, 4000000000)").arg(tableName))); @@ -1778,7 +1783,7 @@ void tst_QSqlDatabase::accessOdbc_strings() } QSqlQuery q(db); - QString tableName = qTableName("strings"); + const QString tableName(qTableName("strings", __FILE__)); QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (aStr memo, bStr memo, cStr memo, dStr memo" ", eStr memo, fStr memo, gStr memo, hStr memo)").arg(tableName))); @@ -1816,7 +1821,7 @@ void tst_QSqlDatabase::ibase_numericFields() CHECK_DATABASE(db); QSqlQuery q(db); - QString tableName = qTableName("numericfields"); + const QString tableName(qTableName("numericfields", __FILE__)); QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (id int not null, num1 NUMERIC(2,1), " "num2 NUMERIC(5,2), num3 NUMERIC(10,3), " "num4 NUMERIC(18,4))").arg(tableName))); @@ -1888,7 +1893,7 @@ void tst_QSqlDatabase::ibase_fetchBlobs() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QString tableName = qTableName("qtest_ibaseblobs"); + const QString tableName(qTableName("qtest_ibaseblobs", __FILE__)); QSqlQuery q(db); QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (blob1 BLOB segment size 256)").arg(tableName))); @@ -1921,7 +1926,7 @@ void tst_QSqlDatabase::ibase_procWithoutReturnValues() CHECK_DATABASE(db); QSqlQuery q(db); - QString procName = qTableName("qtest_proc1"); + const QString procName(qTableName("qtest_proc1", __FILE__)); q.exec(QString("drop procedure %1").arg(procName)); QVERIFY_SQL(q, exec("CREATE PROCEDURE " + procName + " (str VARCHAR(10))\nAS BEGIN\nstr='test';\nEND;")); QVERIFY_SQL(q, exec(QString("execute procedure %1('qtest')").arg(procName))); @@ -1939,7 +1944,7 @@ void tst_QSqlDatabase::ibase_procWithReturnValues() return; } - QString procName = qTableName("qtest_proc2"); + const QString procName(qTableName("qtest_proc2", __FILE__)); QSqlQuery q(db); q.exec(QString("drop procedure %1").arg(procName)); @@ -1981,11 +1986,11 @@ void tst_QSqlDatabase::formatValueTrimStrings() QSqlQuery q(db); - QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (50, 'Trim Test ', 'Trim Test 2 ')").arg(qTableName("qtest")))); - QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (51, 'TrimTest', 'Trim Test 2')").arg(qTableName("qtest")))); - QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (52, ' ', ' ')").arg(qTableName("qtest")))); + QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (50, 'Trim Test ', 'Trim Test 2 ')").arg(qTableName("qtest", __FILE__)))); + QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (51, 'TrimTest', 'Trim Test 2')").arg(qTableName("qtest", __FILE__)))); + QVERIFY_SQL(q, exec(QString("INSERT INTO %1 (id, t_varchar, t_char) values (52, ' ', ' ')").arg(qTableName("qtest", __FILE__)))); - QVERIFY_SQL(q, exec(QString("SELECT t_varchar, t_char FROM %1 WHERE id >= 50 AND id <= 52 ORDER BY id").arg(qTableName("qtest")))); + QVERIFY_SQL(q, exec(QString("SELECT t_varchar, t_char FROM %1 WHERE id >= 50 AND id <= 52 ORDER BY id").arg(qTableName("qtest", __FILE__)))); QVERIFY_SQL(q, next()); @@ -2009,10 +2014,10 @@ void tst_QSqlDatabase::odbc_reopenDatabase() CHECK_DATABASE(db); QSqlQuery q(db); - QVERIFY_SQL(q, exec("SELECT * from " + qTableName("qtest"))); + QVERIFY_SQL(q, exec("SELECT * from " + qTableName("qtest", __FILE__))); QVERIFY_SQL(q, next()); db.open(); - QVERIFY_SQL(q, exec("SELECT * from " + qTableName("qtest"))); + QVERIFY_SQL(q, exec("SELECT * from " + qTableName("qtest", __FILE__))); QVERIFY_SQL(q, next()); db.open(); } @@ -2029,10 +2034,10 @@ void tst_QSqlDatabase::odbc_bindBoolean() } QSqlQuery q(db); - QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("qtestBindBool") + "(id int, boolvalue bit)")); + QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("qtestBindBool", __FILE__) + "(id int, boolvalue bit)")); // Bind and insert - QVERIFY_SQL(q, prepare("INSERT INTO " + qTableName("qtestBindBool") + " VALUES(?, ?)")); + QVERIFY_SQL(q, prepare("INSERT INTO " + qTableName("qtestBindBool", __FILE__) + " VALUES(?, ?)")); q.bindValue(0, 1); q.bindValue(1, true); QVERIFY_SQL(q, exec()); @@ -2041,7 +2046,7 @@ void tst_QSqlDatabase::odbc_bindBoolean() QVERIFY_SQL(q, exec()); // Retrive - QVERIFY_SQL(q, exec("SELECT id, boolvalue FROM " + qTableName("qtestBindBool") + " ORDER BY id")); + QVERIFY_SQL(q, exec("SELECT id, boolvalue FROM " + qTableName("qtestBindBool", __FILE__) + " ORDER BY id")); QVERIFY_SQL(q, next()); QCOMPARE(q.value(0).toInt(), 1); QCOMPARE(q.value(1).toBool(), true); @@ -2055,20 +2060,21 @@ void tst_QSqlDatabase::odbc_testqGetString() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); + const QString testqGetString(qTableName("testqGetString", __FILE__)); QSqlQuery q(db); if (tst_Databases::isSqlServer(db)) - QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue varchar(MAX))")); + QVERIFY_SQL(q, exec("CREATE TABLE " + testqGetString + "(id int, vcvalue varchar(MAX))")); else if(tst_Databases::isMSAccess(db)) - QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue memo)")); + QVERIFY_SQL(q, exec("CREATE TABLE " + testqGetString + "(id int, vcvalue memo)")); else - QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue varchar(65538))")); + QVERIFY_SQL(q, exec("CREATE TABLE " + testqGetString + "(id int, vcvalue varchar(65538))")); QString largeString; largeString.fill('A', 65536); // Bind and insert - QVERIFY_SQL(q, prepare("INSERT INTO " + qTableName("testqGetString") + " VALUES(?, ?)")); + QVERIFY_SQL(q, prepare("INSERT INTO " + testqGetString + " VALUES(?, ?)")); q.bindValue(0, 1); q.bindValue(1, largeString); QVERIFY_SQL(q, exec()); @@ -2080,7 +2086,7 @@ void tst_QSqlDatabase::odbc_testqGetString() QVERIFY_SQL(q, exec()); // Retrive - QVERIFY_SQL(q, exec("SELECT id, vcvalue FROM " + qTableName("testqGetString") + " ORDER BY id")); + QVERIFY_SQL(q, exec("SELECT id, vcvalue FROM " + testqGetString + " ORDER BY id")); QVERIFY_SQL(q, next()); QCOMPARE(q.value(0).toInt(), 1); QCOMPARE(q.value(1).toString().length(), 65536); @@ -2098,6 +2104,7 @@ void tst_QSqlDatabase::mysql_multiselect() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); + const QString qtest(qTableName("qtest", __FILE__)); QSqlQuery q(db); QString version=tst_Databases::getMySqlVersion( db ); @@ -2105,11 +2112,11 @@ void tst_QSqlDatabase::mysql_multiselect() if (ver < 4.1) QSKIP("Test requires MySQL >= 4.1", SkipSingle); - QVERIFY_SQL(q, exec("SELECT * FROM " + qTableName("qtest") + "; SELECT * FROM " + qTableName("qtest"))); + QVERIFY_SQL(q, exec("SELECT * FROM " + qtest + "; SELECT * FROM " + qtest)); QVERIFY_SQL(q, next()); - QVERIFY_SQL(q, exec("SELECT * FROM " + qTableName("qtest") + "; SELECT * FROM " + qTableName("qtest"))); + QVERIFY_SQL(q, exec("SELECT * FROM " + qtest + "; SELECT * FROM " + qtest)); QVERIFY_SQL(q, next()); - QVERIFY_SQL(q, exec("SELECT * FROM " + qTableName("qtest"))); + QVERIFY_SQL(q, exec("SELECT * FROM " + qtest)); } void tst_QSqlDatabase::ibase_useCustomCharset() @@ -2123,7 +2130,7 @@ void tst_QSqlDatabase::ibase_useCustomCharset() db.setConnectOptions("ISC_DPB_LC_CTYPE=Latin1"); db.open(); - QString tableName = qTableName("latin1table"); + const QString tableName(qTableName("latin1table", __FILE__)); QSqlQuery q(db); QVERIFY_SQL(q, exec(QString("CREATE TABLE %1(text VARCHAR(6) CHARACTER SET Latin1)").arg(tableName))); @@ -2161,7 +2168,7 @@ void tst_QSqlDatabase::oci_xmltypeSupport() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QString tableName = qTableName("qtest_xmltype"); + const QString tableName(qTableName("qtest_xmltype", __FILE__)); QString xml("<?xml version=\"1.0\"?><TABLE_NAME>MY_TABLE</TABLE_NAME>"); QSqlQuery q(db); @@ -2189,7 +2196,7 @@ void tst_QSqlDatabase::oci_fieldLength() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QString tableName = qTableName("qtest"); + const QString tableName(qTableName("qtest", __FILE__)); QSqlQuery q(db); QVERIFY_SQL(q, exec(QString("SELECT t_varchar, t_char FROM %1").arg(tableName))); @@ -2205,7 +2212,7 @@ void tst_QSqlDatabase::oci_synonymstest() CHECK_DATABASE(db); QSqlQuery q(db); - QString creator(qTableName("CREATOR")), appuser(qTableName("APPUSER")), table1(qTableName("TABLE1")); + const QString creator(qTableName("CREATOR", __FILE__)), appuser(qTableName("APPUSER", __FILE__)), table1(qTableName("TABLE1", __FILE__)); // QVERIFY_SQL(q, exec("drop public synonym "+table1)); QVERIFY_SQL(q, exec(QString("create user %1 identified by %2 default tablespace users temporary tablespace temp").arg(creator).arg(creator))); QVERIFY_SQL(q, exec(QString("grant CONNECT to %1").arg(creator))); @@ -2223,8 +2230,8 @@ void tst_QSqlDatabase::oci_synonymstest() db3.close(); QVERIFY_SQL(db3, open(appuser,appuser)); QSqlQuery q3(db3); - QVERIFY_SQL(q3, exec("create synonym "+appuser+'.'+qTableName("synonyms")+" for "+creator+'.'+table1)); - QVERIFY_SQL(db3, tables().filter(qTableName("synonyms"), Qt::CaseInsensitive).count() >= 1); + QVERIFY_SQL(q3, exec("create synonym "+appuser+'.'+qTableName("synonyms", __FILE__)+" for "+creator+'.'+table1)); + QVERIFY_SQL(db3, tables().filter(qTableName("synonyms", __FILE__), Qt::CaseInsensitive).count() >= 1); } @@ -2240,7 +2247,7 @@ void tst_QSqlDatabase::odbc_uniqueidentifier() return; } - QString tableName = qTableName("qtest_sqlguid"); + const QString tableName(qTableName("qtest_sqlguid", __FILE__)); QString guid = QString("AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE"); QString invalidGuid = QString("GAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE"); @@ -2283,7 +2290,7 @@ void tst_QSqlDatabase::odbc_uintfield() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QString tableName = qTableName("uint_table"); + const QString tableName(qTableName("uint_table", __FILE__)); unsigned int val = 4294967295U; QSqlQuery q(db); @@ -2347,7 +2354,7 @@ void tst_QSqlDatabase::eventNotificationIBase() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QString procedureName = qTableName("posteventProc"); + const QString procedureName(qTableName("posteventProc", __FILE__)); QSqlDriver *driver=db.driver(); QVERIFY_SQL(*driver, subscribeToNotification(procedureName)); QTest::qWait(300); // Interbase needs some time to call the driver callback. @@ -2381,7 +2388,7 @@ void tst_QSqlDatabase::eventNotificationPSQL() #endif QSqlQuery query(db); - QString procedureName = qTableName("posteventProc"); + QString procedureName = qTableName("posteventProc", __FILE__); QSqlDriver &driver=*(db.driver()); QVERIFY_SQL(driver, subscribeToNotification(procedureName)); @@ -2405,7 +2412,7 @@ void tst_QSqlDatabase::sqlite_bindAndFetchUInt() } QSqlQuery q(db); - QString tableName = qTableName("uint_test"); + const QString tableName(qTableName("uint_test", __FILE__)); QVERIFY_SQL(q, exec(QString("CREATE TABLE %1(uint_field UNSIGNED INTEGER)").arg(tableName))); QVERIFY_SQL(q, prepare(QString("INSERT INTO %1 VALUES(?)").arg(tableName))); q.addBindValue(4000000000U); @@ -2425,7 +2432,7 @@ void tst_QSqlDatabase::db2_valueCacheUpdate() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QString tableName = qTableName("qtest"); + const QString tableName(qTableName("qtest", __FILE__)); QSqlQuery q(db); q.exec(QString("SELECT id, t_varchar, t_char, t_numeric FROM %1").arg(tableName)); q.next(); @@ -2448,7 +2455,7 @@ void tst_QSqlDatabase::sqlStatementUseIsNull_189093() // select a record with NULL value QSqlQuery q(QString::null, db); - QVERIFY_SQL(q, exec("select * from " + qTableName("qtest") + " where id = 4")); + QVERIFY_SQL(q, exec("select * from " + qTableName("qtest", __FILE__) + " where id = 4")); QVERIFY_SQL(q, next()); QSqlDriver *driver = db.driver(); @@ -2471,7 +2478,7 @@ void tst_QSqlDatabase::mysql_savepointtest() QSqlQuery q(db); QVERIFY_SQL(q, exec("begin")); - QVERIFY_SQL(q, exec("insert into "+qTableName("qtest")+" VALUES (54, 'foo', 'foo', 54.54)")); + QVERIFY_SQL(q, exec("insert into "+qTableName("qtest", __FILE__)+" VALUES (54, 'foo', 'foo', 54.54)")); QVERIFY_SQL(q, exec("savepoint foo")); } @@ -2481,7 +2488,7 @@ void tst_QSqlDatabase::oci_tables() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); QSqlQuery q(db); - QString systemTableName("system."+qTableName("mypassword")); + const QString systemTableName("system."+qTableName("mypassword", __FILE__)); QVERIFY_SQL(q, exec("CREATE TABLE "+systemTableName+"(name VARCHAR(20))")); QVERIFY(!db.tables().contains(systemTableName.toUpper())); QVERIFY(db.tables(QSql::SystemTables).contains(systemTableName.toUpper())); @@ -2501,8 +2508,8 @@ void tst_QSqlDatabase::sqlite_enable_cache_mode() db2.setConnectOptions("QSQLITE_ENABLE_SHARED_CACHE"); QVERIFY_SQL(db2, open()); QSqlQuery q(db), q2(db2); - QVERIFY_SQL(q, exec("select * from "+qTableName("qtest"))); - QVERIFY_SQL(q2, exec("select * from "+qTableName("qtest"))); + QVERIFY_SQL(q, exec("select * from "+qTableName("qtest", __FILE__))); + QVERIFY_SQL(q2, exec("select * from "+qTableName("qtest", __FILE__))); } QTEST_MAIN(tst_QSqlDatabase) diff --git a/tests/auto/qsqldriver/tst_qsqldriver.cpp b/tests/auto/qsqldriver/tst_qsqldriver.cpp index 19e4001..f2393ba 100644 --- a/tests/auto/qsqldriver/tst_qsqldriver.cpp +++ b/tests/auto/qsqldriver/tst_qsqldriver.cpp @@ -84,18 +84,19 @@ void tst_QSqlDriver::initTestCase_data() void tst_QSqlDriver::recreateTestTables(QSqlDatabase db) { QSqlQuery q(db); + const QString relTEST1(qTableName("relTEST1", __FILE__)); if(tst_Databases::isPostgreSQL(db)) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); - tst_Databases::safeDropTable( db, qTableName( "relTEST1" ) ); + tst_Databases::safeDropTable( db, relTEST1 ); - QVERIFY_SQL( q, exec("create table " + qTableName("relTEST1") + + QVERIFY_SQL( q, exec("create table " + relTEST1 + " (id int not null primary key, name varchar(20), title_key int, another_title_key int)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("relTEST1") + " values(1, 'harry', 1, 2)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("relTEST1") + " values(2, 'trond', 2, 1)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("relTEST1") + " values(3, 'vohi', 1, 2)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("relTEST1") + " values(4, 'boris', 2, 2)")); + QVERIFY_SQL( q, exec("insert into " + relTEST1 + " values(1, 'harry', 1, 2)")); + QVERIFY_SQL( q, exec("insert into " + relTEST1 + " values(2, 'trond', 2, 1)")); + QVERIFY_SQL( q, exec("insert into " + relTEST1 + " values(3, 'vohi', 1, 2)")); + QVERIFY_SQL( q, exec("insert into " + relTEST1 + " values(4, 'boris', 2, 2)")); } void tst_QSqlDriver::initTestCase() @@ -108,7 +109,7 @@ void tst_QSqlDriver::cleanupTestCase() { foreach (const QString &dbName, dbs.dbNames) { QSqlDatabase db = QSqlDatabase::database(dbName); - tst_Databases::safeDropTable( db, qTableName( "relTEST1" ) ); + tst_Databases::safeDropTable( db, qTableName( "relTEST1", __FILE__ ) ); } dbs.close(); } @@ -127,7 +128,7 @@ void tst_QSqlDriver::record() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QString tablename = qTableName("relTEST1"); + QString tablename(qTableName("relTEST1", __FILE__)); QStringList fields; fields << "id" << "name" << "title_key" << "another_title_key"; @@ -180,7 +181,7 @@ void tst_QSqlDriver::primaryIndex() QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); - QString tablename = qTableName("relTEST1"); + QString tablename(qTableName("relTEST1", __FILE__)); //check that we can get primary index using unquoted mixed case table name QSqlIndex index = db.driver()->primaryIndex(tablename); QCOMPARE(index.count(), 1); diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 5339132..b9ab73f 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -44,6 +44,8 @@ #include "../qsqldatabase/tst_databases.h" +const QString qtest(qTableName( "qtest", __FILE__ )); + //TESTED_FILES= class tst_QSqlQuery : public QObject @@ -295,56 +297,56 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) { QStringList tablenames; // drop all the table in case a testcase failed - tablenames << qTableName( "qtest" ) - << qTableName( "qtest_null" ) - << qTableName( "qtest_blob" ) - << qTableName( "qtest_bittest" ) - << qTableName( "qtest_nullblob" ) - << qTableName( "qtest_rawtest" ) - << qTableName( "qtest_precision" ) - << qTableName( "qtest_prepare" ) - << qTableName( "qtestj1" ) - << qTableName( "qtestj2" ) - << qTableName( "char1Select" ) - << qTableName( "char1SelectUnicode" ) - << qTableName( "qxmltest" ) - << qTableName( "qtest_exerr" ) - << qTableName( "qtest_empty" ) - << qTableName( "clobby" ) - << qTableName( "bindtest" ) - << qTableName( "more_results" ) - << qTableName( "blobstest" ) - << qTableName( "oraRowId" ) - << qTableName( "qtest_batch" ) - << qTableName("bug6421").toUpper() - << qTableName("bug5765") - << qTableName("bug6852") - << qTableName( "qtest_lockedtable" ) - << qTableName( "Planet" ) - << qTableName( "task_250026" ) - << qTableName( "task_234422" ) - << qTableName("test141895"); + tablenames << qtest + << qTableName( "qtest_null", __FILE__ ) + << qTableName( "qtest_blob", __FILE__ ) + << qTableName( "qtest_bittest", __FILE__ ) + << qTableName( "qtest_nullblob", __FILE__ ) + << qTableName( "qtest_rawtest", __FILE__ ) + << qTableName( "qtest_precision", __FILE__ ) + << qTableName( "qtest_prepare", __FILE__ ) + << qTableName( "qtestj1", __FILE__ ) + << qTableName( "qtestj2", __FILE__ ) + << qTableName( "char1Select", __FILE__ ) + << qTableName( "char1SU", __FILE__ ) + << qTableName( "qxmltest", __FILE__ ) + << qTableName( "qtest_exerr", __FILE__ ) + << qTableName( "qtest_empty", __FILE__ ) + << qTableName( "clobby", __FILE__ ) + << qTableName( "bindtest", __FILE__ ) + << qTableName( "more_results", __FILE__ ) + << qTableName( "blobstest", __FILE__ ) + << qTableName( "oraRowId", __FILE__ ) + << qTableName( "qtest_batch", __FILE__ ) + << qTableName("bug6421", __FILE__).toUpper() + << qTableName("bug5765", __FILE__) + << qTableName("bug6852", __FILE__) + << qTableName( "qtest_lockedtable", __FILE__ ) + << qTableName( "Planet", __FILE__ ) + << qTableName( "task_250026", __FILE__ ) + << qTableName( "task_234422", __FILE__ ) + << qTableName("test141895", __FILE__); if ( db.driverName().startsWith("QPSQL") ) - tablenames << qTableName("task_233829"); + tablenames << qTableName("task_233829", __FILE__); if ( db.driverName().startsWith("QSQLITE") ) - tablenames << qTableName( "record_sqlite" ); + tablenames << qTableName( "record_sqlite", __FILE__ ); if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QOCI" ) ) - tablenames << qTableName( "qtest_longstr" ); + tablenames << qTableName( "qtest_longstr", __FILE__ ); if (tst_Databases::isSqlServer( db )) - db.exec("DROP PROCEDURE " + qTableName("test141895_proc")); + db.exec("DROP PROCEDURE " + qTableName("test141895_proc", __FILE__)); if (tst_Databases::isMySQL( db )) - db.exec("DROP PROCEDURE IF EXISTS "+qTableName("bug6852_proc")); + db.exec("DROP PROCEDURE IF EXISTS "+qTableName("bug6852_proc", __FILE__)); tst_Databases::safeDropTables( db, tablenames ); if ( db.driverName().startsWith( "QOCI" ) ) { QSqlQuery q( db ); - q.exec( "DROP PACKAGE " + qTableName("pkg") ); + q.exec( "DROP PACKAGE " + qTableName("pkg", __FILE__) ); } } @@ -360,31 +362,32 @@ void tst_QSqlQuery::createTestTables( QSqlDatabase db ) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); if(tst_Databases::isPostgreSQL(db)) - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest" ) + " (id serial NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id)) WITH OIDS" ) ); + QVERIFY_SQL( q, exec( "create table " + qtest + " (id serial NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id)) WITH OIDS" ) ); else - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest" ) + " (id int "+tst_Databases::autoFieldName(db) +" NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id))" ) ); + QVERIFY_SQL( q, exec( "create table " + qtest + " (id int "+tst_Databases::autoFieldName(db) +" NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id))" ) ); if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QTDS" ) ) - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_null" ) + " (id int null, t_varchar varchar(20) null)" ) ); + QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_null", __FILE__ ) + " (id int null, t_varchar varchar(20) null)" ) ); else - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_null" ) + " (id int, t_varchar varchar(20))" ) ); + QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_null", __FILE__ ) + " (id int, t_varchar varchar(20))" ) ); } void tst_QSqlQuery::populateTestTables( QSqlDatabase db ) { QSqlQuery q( db ); - q.exec( "delete from " + qTableName( "qtest" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest" ) + " values (1, 'VarChar1', 'Char1')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest" ) + " values (2, 'VarChar2', 'Char2')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest" ) + " values (3, 'VarChar3', 'Char3')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest" ) + " values (4, 'VarChar4', 'Char4')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest" ) + " values (5, 'VarChar5', 'Char5')" ) ); + const QString qtest_null(qTableName( "qtest_null", __FILE__ )); + q.exec( "delete from " + qtest ); + QVERIFY_SQL( q, exec( "insert into " + qtest + " values (1, 'VarChar1', 'Char1')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest + " values (2, 'VarChar2', 'Char2')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest + " values (3, 'VarChar3', 'Char3')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest + " values (4, 'VarChar4', 'Char4')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest + " values (5, 'VarChar5', 'Char5')" ) ); - q.exec( "delete from " + qTableName( "qtest_null" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_null" ) + " values (0, NULL)" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_null" ) + " values (1, 'n')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_null" ) + " values (2, 'i')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_null" ) + " values (3, NULL)" ) ); + q.exec( "delete from " + qtest_null ); + QVERIFY_SQL( q, exec( "insert into " + qtest_null + " values (0, NULL)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_null + " values (1, 'n')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_null + " values (2, 'i')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_null + " values (3, NULL)" ) ); } // There were problems with char fields of size 1 @@ -396,9 +399,9 @@ void tst_QSqlQuery::char1Select() { QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "char1Select" ) + " (id char(1))" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "char1Select" ) + " values ('a')" ) ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "char1Select" ) ) ); + QVERIFY_SQL( q, exec( "create table " + qTableName( "char1Select", __FILE__ ) + " (id char(1))" ) ); + QVERIFY_SQL( q, exec( "insert into " + qTableName( "char1Select", __FILE__ ) + " values ('a')" ) ); + QVERIFY_SQL( q, exec( "select * from " + qTableName( "char1Select", __FILE__ ) ) ); QVERIFY( q.next() ); if ( db.driverName().startsWith( "QIBASE" ) ) @@ -427,31 +430,32 @@ void tst_QSqlQuery::char1SelectUnicode() QSKIP( "Test requires MySQL >= 5.0", SkipSingle ); QString createQuery; + const QString char1SelectUnicode(qTableName( "char1SU", __FILE__ )); if ( tst_Databases::isSqlServer( db ) ) - createQuery = "create table " + qTableName( "char1SelectUnicode" ) + "(id nchar(1))"; + createQuery = "create table " + char1SelectUnicode + "(id nchar(1))"; else if ( db.driverName().startsWith( "QDB2" ) || db.driverName().startsWith( "QOCI" ) || db.driverName().startsWith( "QPSQL" ) ) - createQuery = "create table " + qTableName( "char1SelectUnicode" ) + " (id char(3))"; + createQuery = "create table " + char1SelectUnicode + " (id char(3))"; else if ( db.driverName().startsWith( "QIBASE" ) ) - createQuery = "create table " + qTableName( "char1SelectUnicode" ) + + createQuery = "create table " + char1SelectUnicode + " (id char(1) character set unicode_fss)"; else if ( db.driverName().startsWith( "QMYSQL" ) ) - createQuery = "create table " + qTableName( "char1SelectUnicode" ) + " (id char(1)) " + createQuery = "create table " + char1SelectUnicode + " (id char(1)) " "default character set 'utf8'"; else - createQuery = "create table " + qTableName( "char1SelectUnicode" ) + " (id char(1))"; + createQuery = "create table " + char1SelectUnicode + " (id char(1))"; QVERIFY_SQL( q, exec( createQuery ) ); - QVERIFY_SQL( q, prepare( "insert into " + qTableName( "char1SelectUnicode" ) + " values(?)" ) ); + QVERIFY_SQL( q, prepare( "insert into " + char1SelectUnicode + " values(?)" ) ); q.bindValue( 0, uniStr ); QVERIFY_SQL( q, exec() ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "char1SelectUnicode" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + char1SelectUnicode ) ); QVERIFY( q.next() ); @@ -471,24 +475,25 @@ void tst_QSqlQuery::oraRowId() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString oraRowId(qTableName("oraRowId", __FILE__)); QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "select rowid from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select rowid from " + qtest ) ); QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).type(), QVariant::String ); QVERIFY( !q.value( 0 ).toString().isEmpty() ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "oraRowId" ) + " (id char(1))" ) ); + QVERIFY_SQL( q, exec( "create table " + oraRowId + " (id char(1))" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "oraRowId" ) + " values('a')" ) ); + QVERIFY_SQL( q, exec( "insert into " + oraRowId + " values('a')" ) ); QVariant v1 = q.lastInsertId(); QVERIFY( v1.isValid() ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "oraRowId" ) + " values('b')" ) ); + QVERIFY_SQL( q, exec( "insert into " + oraRowId + " values('b')" ) ); QVariant v2 = q.lastInsertId(); QVERIFY( v2.isValid() ); - QVERIFY_SQL( q, prepare( "select * from " + qTableName( "oraRowId" ) + " where rowid = ?" ) ); + QVERIFY_SQL( q, prepare( "select * from " + oraRowId + " where rowid = ?" ) ); q.addBindValue( v1 ); QVERIFY_SQL( q, exec() ); QVERIFY( q.next() ); @@ -505,49 +510,50 @@ void tst_QSqlQuery::mysqlOutValues() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString hello(qTableName( "hello", __FILE__ )), qtestproc(qTableName( "qtestproc", __FILE__ )); QSqlQuery q( db ); if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 ) QSKIP( "Test requires MySQL >= 5.0", SkipSingle ); - q.exec( "drop function " + qTableName( "hello" ) ); + q.exec( "drop function " + hello ); - QVERIFY_SQL( q, exec( "create function " + qTableName( "hello" ) + " (s char(20)) returns varchar(50) return concat('Hello ', s)" ) ); + QVERIFY_SQL( q, exec( "create function " + hello + " (s char(20)) returns varchar(50) return concat('Hello ', s)" ) ); - QVERIFY_SQL( q, exec( "select " + qTableName( "hello" ) + "('world')" ) ); + QVERIFY_SQL( q, exec( "select " + hello + "('world')" ) ); QVERIFY_SQL( q, next() ); QCOMPARE( q.value( 0 ).toString(), QString( "Hello world" ) ); - QVERIFY_SQL( q, prepare( "select " + qTableName( "hello" ) + "('harald')" ) ); + QVERIFY_SQL( q, prepare( "select " + hello + "('harald')" ) ); QVERIFY_SQL( q, exec() ); QVERIFY_SQL( q, next() ); QCOMPARE( q.value( 0 ).toString(), QString( "Hello harald" ) ); - QVERIFY_SQL( q, exec( "drop function " + qTableName( "hello" ) ) ); + QVERIFY_SQL( q, exec( "drop function " + hello ) ); - q.exec( "drop procedure " + qTableName( "qtestproc" ) ); + q.exec( "drop procedure " + qtestproc ); - QVERIFY_SQL( q, exec( "create procedure " + qTableName( "qtestproc" ) + " () " - "BEGIN select * from " + qTableName( "qtest" ) + " order by id; END" ) ); - QVERIFY_SQL( q, exec( "call " + qTableName( "qtestproc" ) + "()" ) ); + QVERIFY_SQL( q, exec( "create procedure " + qtestproc + " () " + "BEGIN select * from " + qtest + " order by id; END" ) ); + QVERIFY_SQL( q, exec( "call " + qtestproc + "()" ) ); QVERIFY_SQL( q, next() ); QCOMPARE( q.value( 1 ).toString(), QString( "VarChar1" ) ); - QVERIFY_SQL( q, exec( "drop procedure " + qTableName( "qtestproc" ) ) ); + QVERIFY_SQL( q, exec( "drop procedure " + qtestproc ) ); - QVERIFY_SQL( q, exec( "create procedure " + qTableName( "qtestproc" ) + " (OUT param1 INT) " + QVERIFY_SQL( q, exec( "create procedure " + qtestproc + " (OUT param1 INT) " "BEGIN set param1 = 42; END" ) ); - QVERIFY_SQL( q, exec( "call " + qTableName( "qtestproc" ) + " (@out)" ) ); + QVERIFY_SQL( q, exec( "call " + qtestproc + " (@out)" ) ); QVERIFY_SQL( q, exec( "select @out" ) ); QCOMPARE( q.record().fieldName( 0 ), QString( "@out" ) ); QVERIFY_SQL( q, next() ); QCOMPARE( q.value( 0 ).toInt(), 42 ); - QVERIFY_SQL( q, exec( "drop procedure " + qTableName( "qtestproc" ) ) ); + QVERIFY_SQL( q, exec( "drop procedure " + qtestproc ) ); } void tst_QSqlQuery::oraOutValues() @@ -555,6 +561,7 @@ void tst_QSqlQuery::oraOutValues() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString tst_outValues(qTableName("tst_outValues", __FILE__)); if ( !db.driver()->hasFeature( QSqlDriver::PreparedQueries ) ) { QSKIP( "Test requires prepared query support", SkipSingle ); @@ -566,11 +573,11 @@ void tst_QSqlQuery::oraOutValues() q.setForwardOnly( true ); /*** outvalue int ***/ - QVERIFY_SQL( q, exec( "create or replace procedure " + qTableName( "tst_outValues" ) + "(x out int) is\n" + QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x out int) is\n" "begin\n" " x := 42;\n" "end;\n" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outvalues" ) + "(?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); q.addBindValue( 0, QSql::Out ); QVERIFY_SQL( q, exec() ); QCOMPARE( q.boundValue( 0 ).toInt(), 42 ); @@ -582,11 +589,11 @@ void tst_QSqlQuery::oraOutValues() QVERIFY( !q.boundValue( 0 ).isNull() ); /*** outvalue varchar ***/ - QVERIFY_SQL( q, exec( "create or replace procedure " + qTableName( "tst_outValues" ) + "(x out varchar) is\n" + QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x out varchar) is\n" "begin\n" " x := 'blah';\n" "end;\n" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outvalues" ) + "(?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); QString s1( "12345" ); s1.reserve( 512 ); q.addBindValue( s1, QSql::Out ); @@ -594,51 +601,51 @@ void tst_QSqlQuery::oraOutValues() QCOMPARE( q.boundValue( 0 ).toString(), QString( "blah" ) ); /*** in/outvalue numeric ***/ - QVERIFY_SQL( q, exec( "create or replace procedure " + qTableName( "tst_outValues" ) + "(x in out numeric) is\n" + QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x in out numeric) is\n" "begin\n" " x := x + 10;\n" "end;\n" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outvalues" ) + "(?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); q.addBindValue( 10, QSql::Out ); QVERIFY_SQL( q, exec() ); QCOMPARE( q.boundValue( 0 ).toInt(), 20 ); /*** in/outvalue varchar ***/ - QVERIFY_SQL( q, exec( "create or replace procedure " + qTableName( "tst_outValues" ) + "(x in out varchar) is\n" + QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x in out varchar) is\n" "begin\n" " x := 'homer';\n" "end;\n" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outvalues" ) + "(?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); q.addBindValue( QString( "maggy" ), QSql::Out ); QVERIFY_SQL( q, exec() ); QCOMPARE( q.boundValue( 0 ).toString(), QString( "homer" ) ); /*** in/outvalue varchar ***/ - QVERIFY_SQL( q, exec( "create or replace procedure " + qTableName( "tst_outValues" ) + "(x in out varchar) is\n" + QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x in out varchar) is\n" "begin\n" " x := NULL;\n" "end;\n" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outvalues" ) + "(?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); q.addBindValue( QString( "maggy" ), QSql::Out ); QVERIFY_SQL( q, exec() ); QVERIFY( q.boundValue( 0 ).isNull() ); /*** in/outvalue int ***/ - QVERIFY_SQL( q, exec( "create or replace procedure " + qTableName( "tst_outValues" ) + "(x in out int) is\n" + QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x in out int) is\n" "begin\n" " x := NULL;\n" "end;\n" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outvalues" ) + "(?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); q.addBindValue( 42, QSql::Out ); QVERIFY_SQL( q, exec() ); QVERIFY( q.boundValue( 0 ).isNull() ); /*** in/outvalue varchar ***/ - QVERIFY_SQL( q, exec( "create or replace procedure " + qTableName( "tst_outValues" ) + "(x in varchar, y out varchar) is\n" + QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x in varchar, y out varchar) is\n" "begin\n" " y := x||'bubulalakikikokololo';\n" "end;\n" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outvalues" ) + "(?, ?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?, ?)" ) ); q.addBindValue( QString( "fifi" ), QSql::In ); QString out; out.reserve( 50 ); @@ -652,30 +659,31 @@ void tst_QSqlQuery::oraClob() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString clobby(qTableName("clobby", __FILE__)); QSqlQuery q( db ); // simple short string - QVERIFY_SQL( q, exec( "create table " + qTableName( "clobby" ) + "(id int primary key, cl clob, bl blob)" ) ); - QVERIFY_SQL( q, prepare( "insert into " + qTableName( "clobby" ) + " (id, cl, bl) values(?, ?, ?)" ) ); + QVERIFY_SQL( q, exec( "create table " + clobby + "(id int primary key, cl clob, bl blob)" ) ); + QVERIFY_SQL( q, prepare( "insert into " + clobby + " (id, cl, bl) values(?, ?, ?)" ) ); q.addBindValue( 1 ); q.addBindValue( "bubu" ); q.addBindValue( QByteArray("bubu") ); QVERIFY_SQL( q, exec() ); - QVERIFY_SQL( q, exec( "select bl, cl from " + qTableName( "clobby" ) + " where id = 1" ) ); + QVERIFY_SQL( q, exec( "select bl, cl from " + clobby + " where id = 1" ) ); QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).toString(), QString( "bubu" ) ); QCOMPARE( q.value( 1 ).toString(), QString( "bubu" ) ); // simple short string with binding - QVERIFY_SQL( q, prepare( "insert into " + qTableName( "clobby" ) + " (id, cl, bl) values(?, ?, ?)" ) ); + QVERIFY_SQL( q, prepare( "insert into " + clobby + " (id, cl, bl) values(?, ?, ?)" ) ); q.addBindValue( 2 ); q.addBindValue( "lala", QSql::Binary ); q.addBindValue( QByteArray("lala"), QSql::Binary ); QVERIFY_SQL( q, exec() ); - QVERIFY_SQL( q, exec( "select bl, cl from " + qTableName( "clobby" ) + " where id = 2" ) ); + QVERIFY_SQL( q, exec( "select bl, cl from " + clobby + " where id = 2" ) ); QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).toString(), QString( "lala" ) ); QCOMPARE( q.value( 1 ).toString(), QString( "lala" ) ); @@ -683,13 +691,13 @@ void tst_QSqlQuery::oraClob() // loooong string QString loong; loong.fill( QLatin1Char( 'A' ), 25000 ); - QVERIFY_SQL( q, prepare( "insert into " + qTableName( "clobby" ) + " (id, cl, bl) values(?, ?, ?)" ) ); + QVERIFY_SQL( q, prepare( "insert into " + clobby + " (id, cl, bl) values(?, ?, ?)" ) ); q.addBindValue( 3 ); q.addBindValue( loong, QSql::Binary ); q.addBindValue( loong.toLatin1(), QSql::Binary ); QVERIFY_SQL( q, exec() ); - QVERIFY_SQL( q, exec( "select bl, cl from " + qTableName( "clobby" ) + " where id = 3" ) ); + QVERIFY_SQL( q, exec( "select bl, cl from " + clobby + " where id = 3" ) ); QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).toString().count(), loong.count() ); QVERIFY( q.value( 0 ).toString() == loong ); @@ -704,16 +712,16 @@ void tst_QSqlQuery::storedProceduresIBase() CHECK_DATABASE( db ); QSqlQuery q( db ); - q.exec( "drop procedure " + qTableName( "TESTPROC" ) ); + q.exec( "drop procedure " + qTableName( "TESTPROC", __FILE__ ) ); - QVERIFY_SQL( q, exec( "create procedure " + qTableName( "TESTPROC" ) + + QVERIFY_SQL( q, exec( "create procedure " + qTableName( "TESTPROC", __FILE__ ) + " RETURNS (x integer, y varchar(20)) " "AS BEGIN " " x = 42; " " y = 'Hello Anders'; " "END" ) ); - QVERIFY_SQL( q, prepare( "execute procedure " + qTableName( "TestProc" ) ) ); + QVERIFY_SQL( q, prepare( "execute procedure " + qTableName( "TestProc", __FILE__ ) ) ); QVERIFY_SQL( q, exec() ); // check for a valid result set @@ -730,7 +738,7 @@ void tst_QSqlQuery::storedProceduresIBase() // the second next shall fail QVERIFY( !q.next() ); - q.exec( "drop procedure " + qTableName( "TestProc" ) ); + q.exec( "drop procedure " + qTableName( "TestProc", __FILE__ ) ); } void tst_QSqlQuery::outValuesDB2() @@ -748,8 +756,8 @@ void tst_QSqlQuery::outValuesDB2() q.setForwardOnly( true ); - q.exec( "drop procedure " + qTableName( "tst_outValues" ) ); //non-fatal - QVERIFY_SQL( q, exec( "CREATE PROCEDURE " + qTableName( "tst_outValues" ) + + q.exec( "drop procedure " + qTableName( "tst_outValues", __FILE__ ) ); //non-fatal + QVERIFY_SQL( q, exec( "CREATE PROCEDURE " + qTableName( "tst_outValues", __FILE__ ) + " (OUT x int, OUT x2 double, OUT x3 char(20))\n" "LANGUAGE SQL\n" "P1: BEGIN\n" @@ -758,7 +766,7 @@ void tst_QSqlQuery::outValuesDB2() " SET x3 = 'Homer';\n" "END P1" ) ); - QVERIFY_SQL( q, prepare( "call " + qTableName( "tst_outValues" ) + "(?, ?, ?)" ) ); + QVERIFY_SQL( q, prepare( "call " + qTableName( "tst_outValues", __FILE__ ) + "(?, ?, ?)" ) ); q.addBindValue( 0, QSql::Out ); q.addBindValue( 0.0, QSql::Out ); @@ -776,6 +784,7 @@ void tst_QSqlQuery::outValues() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString tst_outValues(qTableName("tst_outValues", __FILE__)); if ( !db.driver()->hasFeature( QSqlDriver::PreparedQueries ) ) { QSKIP( "Test requires prepared query support", SkipSingle ); @@ -787,26 +796,26 @@ void tst_QSqlQuery::outValues() q.setForwardOnly( true ); if ( db.driverName().startsWith( "QOCI" ) ) { - QVERIFY_SQL( q, exec( "create or replace procedure " + qTableName( "tst_outValues" ) + "(x out int) is\n" + QVERIFY_SQL( q, exec( "create or replace procedure " + tst_outValues + "(x out int) is\n" "begin\n" " x := 42;\n" "end;\n" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outvalues" ) + "(?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); } else if ( db.driverName().startsWith( "QDB2" ) ) { - q.exec( "drop procedure " + qTableName( "tst_outValues" ) ); //non-fatal - QVERIFY_SQL( q, exec( "CREATE PROCEDURE " + qTableName( "tst_outValues" ) + " (OUT x int)\n" + q.exec( "drop procedure " + tst_outValues ); //non-fatal + QVERIFY_SQL( q, exec( "CREATE PROCEDURE " + tst_outValues + " (OUT x int)\n" "LANGUAGE SQL\n" "P1: BEGIN\n" " SET x = 42;\n" "END P1" ) ); - QVERIFY( q.prepare( "call " + qTableName( "tst_outValues" ) + "(?)" ) ); + QVERIFY( q.prepare( "call " + tst_outValues + "(?)" ) ); } else if ( tst_Databases::isSqlServer( db ) ) { - q.exec( "drop procedure " + qTableName( "tst_outValues" ) ); //non-fatal - QVERIFY_SQL( q, exec( "create procedure " + qTableName( "tst_outValues" ) + " (@x int out) as\n" + q.exec( "drop procedure " + tst_outValues ); //non-fatal + QVERIFY_SQL( q, exec( "create procedure " + tst_outValues + " (@x int out) as\n" "begin\n" " set @x = 42\n" "end\n" ) ); - QVERIFY( q.prepare( "{call " + qTableName( "tst_outvalues" ) + "(?)}" ) ); + QVERIFY( q.prepare( "{call " + tst_outValues + "(?)}" ) ); } else { QSKIP( "Don't know how to create a stored procedure for this database server, please fix this test", SkipSingle ); return; @@ -843,11 +852,11 @@ void tst_QSqlQuery::blob() q.setForwardOnly( true ); - QString queryString = QString( "create table " + qTableName( "qtest_blob" ) + + QString queryString = QString( "create table " + qTableName( "qtest_blob", __FILE__ ) + " (id int not null primary key, t_blob %1)" ).arg( tst_Databases::blobTypeName( db, BLOBSIZE ) ); QVERIFY_SQL( q, exec( queryString ) ); - QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_blob" ) + " (id, t_blob) values (?, ?)" ) ); + QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_blob", __FILE__ ) + " (id, t_blob) values (?, ?)" ) ); for ( i = 0; i < BLOBCOUNT; ++i ) { q.addBindValue( i ); @@ -855,7 +864,7 @@ void tst_QSqlQuery::blob() QVERIFY_SQL( q, exec() ); } - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest_blob" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest_blob", __FILE__ ) ) ); for ( i = 0; i < BLOBCOUNT; ++i ) { QVERIFY( q.next() ); @@ -878,7 +887,7 @@ void tst_QSqlQuery::value() CHECK_DATABASE( db ); QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "select id, t_varchar, t_char from " + qTableName( "qtest" ) + " order by id" ) ); + QVERIFY_SQL( q, exec( "select id, t_varchar, t_char from " + qtest + " order by id" ) ); int i = 1; while ( q.next() ) { @@ -910,7 +919,7 @@ void tst_QSqlQuery::record() QSqlQuery q( db ); QVERIFY( q.record().isEmpty() ); - QVERIFY_SQL( q, exec( "select id, t_varchar, t_char from " + qTableName( "qtest" ) + " order by id" ) ); + 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" ) ); @@ -934,7 +943,7 @@ void tst_QSqlQuery::isValid() QSqlQuery q( db ); QVERIFY( !q.isValid() ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); QVERIFY( q.first() ); QVERIFY( q.isValid() ); } @@ -947,7 +956,7 @@ void tst_QSqlQuery::isActive() QSqlQuery q( db ); QVERIFY( !q.isActive() ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); QVERIFY( q.isActive() ); QVERIFY( q.last() ); @@ -957,15 +966,15 @@ void tst_QSqlQuery::isActive() QVERIFY( q.isActive() ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest" ) + " values (41, 'VarChar41', 'Char41')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest + " values (41, 'VarChar41', 'Char41')" ) ); QVERIFY( q.isActive() ); - QVERIFY_SQL( q, exec( "update " + qTableName( "qtest" ) + " set id = 42 where id = 41" ) ); + QVERIFY_SQL( q, exec( "update " + qtest + " set id = 42 where id = 41" ) ); QVERIFY( q.isActive() ); - QVERIFY_SQL( q, exec( "delete from " + qTableName( "qtest" ) + " where id = 42" ) ); + QVERIFY_SQL( q, exec( "delete from " + qtest + " where id = 42" ) ); QVERIFY( q.isActive() ); } @@ -979,7 +988,7 @@ void tst_QSqlQuery::numRowsAffected() QSqlQuery q( db ); QCOMPARE( q.numRowsAffected(), -1 ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); int i = 0; while ( q.next() ) @@ -993,21 +1002,21 @@ void tst_QSqlQuery::numRowsAffected() qDebug( "Expected numRowsAffected to be -1, 0 or %d, got %d", i, q.numRowsAffected() ); } - QVERIFY_SQL( q, exec( "update " + qTableName( "qtest" ) + " set id = 100 where id = 1" ) ); + QVERIFY_SQL( q, exec( "update " + qtest + " set id = 100 where id = 1" ) ); QCOMPARE( q.numRowsAffected(), 1 ); QCOMPARE( q.numRowsAffected(), 1 ); // yes, we check twice - QVERIFY_SQL( q, exec( "update " + qTableName( "qtest" ) + " set id = id + 100" ) ); + QVERIFY_SQL( q, exec( "update " + qtest + " set id = id + 100" ) ); QCOMPARE( q.numRowsAffected(), i ); QCOMPARE( q.numRowsAffected(), i ); // yes, we check twice - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest" ) + " values (42000, 'homer', 'marge')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest + " values (42000, 'homer', 'marge')" ) ); QCOMPARE( q.numRowsAffected(), 1 ); QCOMPARE( q.numRowsAffected(), 1 ); // yes, we check twice QSqlQuery q2( db ); - QVERIFY_SQL( q2, exec( "insert into " + qTableName( "qtest" ) + " values (42001, 'homer', 'marge')" ) ); + QVERIFY_SQL( q2, exec( "insert into " + qtest + " values (42001, 'homer', 'marge')" ) ); if ( !db.driverName().startsWith( "QSQLITE2" ) ) { // SQLite 2.x accumulates changed rows in nested queries. See task 33794 @@ -1025,7 +1034,7 @@ void tst_QSqlQuery::size() QSqlQuery q( db ); QCOMPARE( q.size(), -1 ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); int i = 0; while ( q.next() ) @@ -1039,7 +1048,7 @@ void tst_QSqlQuery::size() QCOMPARE( q.size(), -1 ); // yes, twice } - QSqlQuery q2( "select * from " + qTableName( "qtest" ), db ); + QSqlQuery q2( "select * from " + qtest, db ); if ( db.driver()->hasFeature( QSqlDriver::QuerySize ) ) QCOMPARE( q.size(), i ); @@ -1048,7 +1057,7 @@ void tst_QSqlQuery::size() q2.clear(); - QVERIFY_SQL( q, exec( "update " + qTableName( "qtest" ) + " set id = 100 where id = 1" ) ); + QVERIFY_SQL( q, exec( "update " + qtest + " set id = 100 where id = 1" ) ); QCOMPARE( q.size(), -1 ); QCOMPARE( q.size(), -1 ); // yes, twice } @@ -1060,10 +1069,10 @@ void tst_QSqlQuery::isSelect() CHECK_DATABASE( db ); QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); QVERIFY( q.isSelect() ); - QVERIFY_SQL( q, exec( "update " + qTableName( "qtest" ) + " set id = 1 where id = 1" ) ); + QVERIFY_SQL( q, exec( "update " + qtest + " set id = 1 where id = 1" ) ); QVERIFY( q.isSelect() == false ); } @@ -1075,7 +1084,7 @@ void tst_QSqlQuery::first() QSqlQuery q( db ); QVERIFY( q.at() == QSql::BeforeFirstRow ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); QVERIFY( q.last() ); QVERIFY_SQL( q, first() ); QVERIFY( q.at() == 0 ); @@ -1089,7 +1098,7 @@ void tst_QSqlQuery::next() QSqlQuery q( db ); QVERIFY( q.at() == QSql::BeforeFirstRow ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); QVERIFY( q.first() ); QVERIFY( q.next() ); QVERIFY( q.at() == 1 ); @@ -1103,7 +1112,7 @@ void tst_QSqlQuery::prev() QSqlQuery q( db ); QVERIFY( q.at() == QSql::BeforeFirstRow ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); QVERIFY( q.first() ); QVERIFY( q.next() ); QVERIFY( q.previous() ); @@ -1118,7 +1127,7 @@ void tst_QSqlQuery::last() QSqlQuery q( db ); QCOMPARE( q.at(), int( QSql::BeforeFirstRow ) ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); int i = 0; while ( q.next() ) @@ -1132,7 +1141,7 @@ void tst_QSqlQuery::last() // Access doesn't return the correct position QCOMPARE( q.at(), ( i-1 ) ); - QSqlQuery q2( "select * from " + qTableName( "qtest" ), db ); + QSqlQuery q2( "select * from " + qtest, db ); QVERIFY( q2.last() ); @@ -1148,7 +1157,7 @@ void tst_QSqlQuery::seek() CHECK_DATABASE( db ); QSqlQuery q( db ); QVERIFY( q.at() == QSql::BeforeFirstRow ); - QVERIFY_SQL( q, exec( QString( "select id from %1 order by id" ).arg( qTableName( "qtest" ) ) ) ); + QVERIFY_SQL( q, exec( QString( "select id from %1 order by id" ).arg( qtest ) ) ); // NB! The order of the calls below are important! QVERIFY( q.last() ); @@ -1184,7 +1193,7 @@ void tst_QSqlQuery::seekForwardOnlyQuery() QVERIFY( !q.isForwardOnly() ); QVERIFY( q.at() == QSql::BeforeFirstRow ); - QVERIFY_SQL( q, exec( QString( "select id from %1 order by id" ).arg( qTableName( "qtest" ) ) ) ); + QVERIFY_SQL( q, exec( QString( "select id from %1 order by id" ).arg( qtest ) ) ); QSqlRecord rec; @@ -1223,7 +1232,7 @@ void tst_QSqlQuery::forwardOnly() q.setForwardOnly( true ); QVERIFY( q.isForwardOnly() ); QVERIFY( q.at() == QSql::BeforeFirstRow ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) + " order by id" ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest + " order by id" ) ); QVERIFY( q.at() == QSql::BeforeFirstRow ); QVERIFY( q.first() ); QCOMPARE( q.at(), 0 ); @@ -1248,7 +1257,7 @@ void tst_QSqlQuery::forwardOnly() QCOMPARE( q.at(), 3 ); QCOMPARE( q.value( 0 ).toInt(), 4 ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); int i = 0; while ( q.next() ) @@ -1260,7 +1269,7 @@ void tst_QSqlQuery::forwardOnly() QVERIFY( q2.isForwardOnly() ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) + " order by id" ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest + " order by id" ) ); QVERIFY( q.isForwardOnly() ); @@ -1306,7 +1315,7 @@ void tst_QSqlQuery::query_exec() QSqlQuery q( db ); QVERIFY( !q.isValid() ); QVERIFY( !q.isActive() ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest ) ); QVERIFY( q.isActive() ); QVERIFY( q.next() ); QVERIFY( q.isValid() ); @@ -1319,7 +1328,7 @@ void tst_QSqlQuery::isNull() CHECK_DATABASE( db ); QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "select id, t_varchar from " + qTableName( "qtest_null" ) + " order by id" ) ); + QVERIFY_SQL( q, exec( "select id, t_varchar from " + qTableName( "qtest_null", __FILE__ ) + " order by id" ) ); QVERIFY( q.next() ); QVERIFY( !q.isNull( 0 ) ); QVERIFY( q.isNull( 1 ) ); @@ -1345,13 +1354,13 @@ void tst_QSqlQuery::bitField() QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_bittest" ) + " (bitty bit)" ) ); + QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_bittest", __FILE__ ) + " (bitty bit)" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_bittest" ) + " values (0)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_bittest", __FILE__ ) + " values (0)" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_bittest" ) + " values (1)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_bittest", __FILE__ ) + " values (1)" ) ); - QVERIFY_SQL( q, exec( "select bitty from " + qTableName( "qtest_bittest" ) ) ); + QVERIFY_SQL( q, exec( "select bitty from " + qTableName( "qtest_bittest", __FILE__ ) ) ); QVERIFY( q.next() ); @@ -1369,15 +1378,16 @@ void tst_QSqlQuery::nullBlob() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString qtest_nullblob(qTableName("qtest_nullblob", __FILE__)); QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_nullblob" ) + " (id int primary key, bb blob)" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_nullblob" ) + " values (0, EMPTY_BLOB())" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_nullblob" ) + " values (1, NULL)" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_nullblob" ) + " values (2, 'aabbcc00112233445566')" ) ); + QVERIFY_SQL( q, exec( "create table " + qtest_nullblob + " (id int primary key, bb blob)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_nullblob + " values (0, EMPTY_BLOB())" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_nullblob + " values (1, NULL)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_nullblob + " values (2, 'aabbcc00112233445566')" ) ); // necessary otherwise oracle will bombard you with internal errors q.setForwardOnly( true ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest_nullblob" ) + " order by id" ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest_nullblob + " order by id" ) ); QVERIFY( q.next() ); QCOMPARE(( int )q.value( 1 ).toByteArray().size(), 0 ); @@ -1398,14 +1408,15 @@ void tst_QSqlQuery::rawField() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString qtest_rawtest(qTableName("qtest_rawtest", __FILE__)); QSqlQuery q( db ); q.setForwardOnly( true ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_rawtest" ) + + QVERIFY_SQL( q, exec( "create table " + qtest_rawtest + " (id int, col raw(20))" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_rawtest" ) + " values (0, NULL)" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_rawtest" ) + " values (1, '00aa1100ddeeff')" ) ); - QVERIFY_SQL( q, exec( "select col from " + qTableName( "qtest_rawtest" ) + " order by id" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_rawtest + " values (0, NULL)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_rawtest + " values (1, '00aa1100ddeeff')" ) ); + QVERIFY_SQL( q, exec( "select col from " + qtest_rawtest + " order by id" ) ); QVERIFY( q.next() ); QVERIFY( q.isNull( 0 ) ); QCOMPARE(( int )q.value( 0 ).toByteArray().size(), 0 ); @@ -1422,6 +1433,7 @@ void tst_QSqlQuery::precision() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString qtest_precision(qTableName( "qtest_precision", __FILE__ )); static const char* precStr = "1.2345678901234567891"; @@ -1433,13 +1445,13 @@ void tst_QSqlQuery::precision() QSqlQuery q( db ); if ( tst_Databases::isMSAccess( db ) ) - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_precision" ) + " (col1 number)" ) ); + QVERIFY_SQL( q, exec( "create table " + qtest_precision + " (col1 number)" ) ); else - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_precision" ) + " (col1 numeric(21, 20))" ) ); + QVERIFY_SQL( q, exec( "create table " + qtest_precision + " (col1 numeric(21, 20))" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest_precision" ) + " (col1) values (1.2345678901234567891)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest_precision + " (col1) values (1.2345678901234567891)" ) ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest_precision" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest_precision ) ); QVERIFY( q.next() ); QString val = q.value( 0 ).toString(); @@ -1472,7 +1484,7 @@ void tst_QSqlQuery::nullResult() CHECK_DATABASE( db ); QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest" ) + " where id > 50000" ) ); + QVERIFY_SQL( q, exec( "select * from " + qtest + " where id > 50000" ) ); if ( q.driver()->hasFeature( QSqlDriver::QuerySize ) ) QCOMPARE( q.size(), 0 ); @@ -1513,9 +1525,9 @@ void tst_QSqlQuery::transaction() // test a working transaction q.exec( startTransactionStr ); - QVERIFY_SQL( q, exec( "insert into" + qTableName( "qtest" ) + " values (40, 'VarChar40', 'Char40')" ) ); + QVERIFY_SQL( q, exec( "insert into" + qtest + " values (40, 'VarChar40', 'Char40')" ) ); - QVERIFY_SQL( q, exec( "select * from" + qTableName( "qtest" ) + " where id = 40" ) ); + QVERIFY_SQL( q, exec( "select * from" + qtest + " where id = 40" ) ); QVERIFY( q.next() ); @@ -1523,7 +1535,7 @@ void tst_QSqlQuery::transaction() QVERIFY_SQL( q, exec( "commit" ) ); - QVERIFY_SQL( q, exec( "select * from" + qTableName( "qtest" ) + " where id = 40" ) ); + QVERIFY_SQL( q, exec( "select * from" + qtest + " where id = 40" ) ); QVERIFY( q.next() ); @@ -1532,9 +1544,9 @@ void tst_QSqlQuery::transaction() // test a rollback q.exec( startTransactionStr ); - QVERIFY_SQL( q, exec( "insert into" + qTableName( "qtest" ) + " values (41, 'VarChar41', 'Char41')" ) ); + QVERIFY_SQL( q, exec( "insert into" + qtest + " values (41, 'VarChar41', 'Char41')" ) ); - QVERIFY_SQL( q, exec( "select * from" + qTableName( "qtest" ) + " where id = 41" ) ); + QVERIFY_SQL( q, exec( "select * from" + qtest + " where id = 41" ) ); QVERIFY( q.next() ); @@ -1548,18 +1560,18 @@ void tst_QSqlQuery::transaction() QFAIL( "Could not rollback transaction: " + tst_Databases::printError( q.lastError() ) ); } - QVERIFY_SQL( q, exec( "select * from" + qTableName( "qtest" ) + " where id = 41" ) ); + QVERIFY_SQL( q, exec( "select * from" + qtest + " where id = 41" ) ); QVERIFY( q.next() == false ); // test concurrent access q.exec( startTransactionStr ); - QVERIFY_SQL( q, exec( "insert into" + qTableName( "qtest" ) + " values (42, 'VarChar42', 'Char42')" ) ); - QVERIFY_SQL( q, exec( "select * from" + qTableName( "qtest" ) + " where id = 42" ) ); + QVERIFY_SQL( q, exec( "insert into" + qtest + " values (42, 'VarChar42', 'Char42')" ) ); + QVERIFY_SQL( q, exec( "select * from" + qtest + " where id = 42" ) ); QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).toInt(), 42 ); - QVERIFY_SQL( q2, exec( "select * from" + qTableName( "qtest" ) + " where id = 42" ) ); + QVERIFY_SQL( q2, exec( "select * from" + qtest + " where id = 42" ) ); if ( q2.next() ) qDebug( QString( "DBMS '%1' doesn't support query based transactions with concurrent access" ).arg( @@ -1567,7 +1579,7 @@ void tst_QSqlQuery::transaction() QVERIFY_SQL( q, exec( "commit" ) ); - QVERIFY_SQL( q2, exec( "select * from" + qTableName( "qtest" ) + " where id = 42" ) ); + QVERIFY_SQL( q2, exec( "select * from" + qtest + " where id = 42" ) ); QVERIFY( q2.next() ); @@ -1579,6 +1591,7 @@ void tst_QSqlQuery::joins() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString qtestj1(qTableName("qtestj1", __FILE__)), qtestj2(qTableName("qtestj2", __FILE__)); if ( db.driverName().startsWith( "QOCI" ) || db.driverName().startsWith( "QTDS" ) @@ -1592,17 +1605,17 @@ void tst_QSqlQuery::joins() QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtestj1" ) + " (id1 int, id2 int)" ) ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtestj2" ) + " (id int, name varchar(20))" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtestj1" ) + " values (1, 1)" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtestj1" ) + " values (1, 2)" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtestj2" ) + " values(1, 'trenton')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtestj2" ) + " values(2, 'marius')" ) ); + QVERIFY_SQL( q, exec( "create table " + qtestj1 + " (id1 int, id2 int)" ) ); + QVERIFY_SQL( q, exec( "create table " + qtestj2 + " (id int, name varchar(20))" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtestj1 + " values (1, 1)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtestj1 + " values (1, 2)" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtestj2 + " values(1, 'trenton')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtestj2 + " values(2, 'marius')" ) ); QVERIFY_SQL( q, exec( "select qtestj1.id1, qtestj1.id2, qtestj2.id, qtestj2.name, qtestj3.id, qtestj3.name " - "from " + qTableName( "qtestj1" ) + " qtestj1 left outer join " + qTableName( "qtestj2" ) + + "from " + qtestj1 + " qtestj1 left outer join " + qtestj2 + " qtestj2 on (qtestj1.id1 = qtestj2.id) " - "left outer join " + qTableName( "qtestj2" ) + " as qtestj3 on (qtestj1.id2 = qtestj3.id)" ) ); + "left outer join " + qtestj2 + " as qtestj3 on (qtestj1.id2 = qtestj3.id)" ) ); QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).toInt(), 1 ); @@ -1628,7 +1641,7 @@ void tst_QSqlQuery::synonyms() CHECK_DATABASE( db ); QSqlQuery q(db); - QVERIFY_SQL( q, exec("select a.id, a.t_char, a.t_varchar from " + qTableName( "qtest" ) + " a where a.id = 1") ); + QVERIFY_SQL( q, exec("select a.id, a.t_char, a.t_varchar from " + qtest + " a where a.id = 1") ); QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).toInt(), 1 ); QCOMPARE( q.value( 1 ).toString().trimmed(), QString( "Char1" ) ); @@ -1647,6 +1660,8 @@ void tst_QSqlQuery::prepare_bind_exec() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString qtest_prepare(qTableName("qtest_prepare", __FILE__)); + if(db.driverName().startsWith("QIBASE") && (db.databaseName() == "silence.nokia.troll.no:c:\\ibase\\testdb_ascii" || db.databaseName() == "/opt/interbase/qttest.gdb")) QSKIP("Can't transliterate extended unicode to ascii", SkipSingle); if(db.driverName().startsWith("QDB2")) @@ -1671,15 +1686,15 @@ void tst_QSqlQuery::prepare_bind_exec() QVERIFY_SQL( q, exec("set client_min_messages='warning'")); if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QTDS" ) ) - createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int primary key, name nvarchar(200) null)"; + createQuery = "create table " + qtest_prepare + " (id int primary key, name nvarchar(200) null)"; else if ( tst_Databases::isMySQL(db) && useUnicode ) - createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int not null primary key, name varchar(200) character set utf8)"; + createQuery = "create table " + qtest_prepare + " (id int not null primary key, name varchar(200) character set utf8)"; else - createQuery = "create table " + qTableName( "qtest_prepare" ) + " (id int not null primary key, name varchar(200))"; + createQuery = "create table " + qtest_prepare + " (id int not null primary key, name varchar(200))"; QVERIFY_SQL( q, exec( createQuery ) ); - QVERIFY( q.prepare( "insert into " + qTableName( "qtest_prepare" ) + " (id, name) values (:id, :name)" ) ); + QVERIFY( q.prepare( "insert into " + qtest_prepare + " (id, name) values (:id, :name)" ) ); int i; for ( i = 0; i < 6; ++i ) { @@ -1702,7 +1717,7 @@ void tst_QSqlQuery::prepare_bind_exec() QVERIFY_SQL( q, exec() ); } - QVERIFY_SQL( q, exec( "SELECT * FROM " + qTableName( "qtest_prepare" ) + " order by id" ) ); + QVERIFY_SQL( q, exec( "SELECT * FROM " + qtest_prepare + " order by id" ) ); for ( i = 0; i < 6; ++i ) { QVERIFY( q.next() ); @@ -1721,12 +1736,12 @@ void tst_QSqlQuery::prepare_bind_exec() QCOMPARE( q.value( 0 ).toInt(), 8 ); QCOMPARE( q.value( 1 ).toString(), values[5] ); - QVERIFY( q.prepare( "insert into " + qTableName( "qtest_prepare" ) + " (id, name) values (:id, 'Bart')" ) ); + QVERIFY( q.prepare( "insert into " + qtest_prepare + " (id, name) values (:id, 'Bart')" ) ); q.bindValue( ":id", 99 ); QVERIFY_SQL( q, exec() ); q.bindValue( ":id", 100 ); QVERIFY_SQL( q, exec() ); - QVERIFY( q.exec( "select * from " + qTableName( "qtest_prepare" ) + " where id > 98 order by id" ) ); + QVERIFY( q.exec( "select * from " + qtest_prepare + " where id > 98 order by id" ) ); for ( i = 99; i <= 100; ++i ) { QVERIFY( q.next() ); @@ -1735,7 +1750,7 @@ void tst_QSqlQuery::prepare_bind_exec() } /*** SELECT stuff ***/ - QVERIFY( q.prepare( "select * from " + qTableName( "qtest_prepare" ) + " where id = :id" ) ); + QVERIFY( q.prepare( "select * from " + qtest_prepare + " where id = :id" ) ); for ( i = 0; i < 6; ++i ) { q.bindValue( ":id", i ); @@ -1750,9 +1765,9 @@ void tst_QSqlQuery::prepare_bind_exec() QVERIFY( !q.next() ); } - QVERIFY_SQL( q, exec( "DELETE FROM " + qTableName( "qtest_prepare" ) ) ); + QVERIFY_SQL( q, exec( "DELETE FROM " + qtest_prepare ) ); - QVERIFY( q.prepare( "insert into " + qTableName( "qtest_prepare" ) + " (id, name) values (?, ?)" ) ); + QVERIFY( q.prepare( "insert into " + qtest_prepare + " (id, name) values (?, ?)" ) ); q.bindValue( 0, 0 ); q.bindValue( 1, values[ 0 ] ); QVERIFY_SQL( q, exec() ); @@ -1781,7 +1796,7 @@ void tst_QSqlQuery::prepare_bind_exec() QVERIFY_SQL( q, exec() ); } - QVERIFY_SQL( q, exec( "SELECT * FROM " + qTableName( "qtest_prepare" ) + " order by id" ) ); + QVERIFY_SQL( q, exec( "SELECT * FROM " + qtest_prepare + " order by id" ) ); for ( i = 0; i < 6; ++i ) { QVERIFY( q.next() ); @@ -1800,13 +1815,13 @@ void tst_QSqlQuery::prepare_bind_exec() QCOMPARE( q.value( 1 ).toString(), utf8str ); } - QVERIFY( q.prepare( "insert into " + qTableName( "qtest_prepare" ) + " (id, name) values (?, 'Bart')" ) ); + QVERIFY( q.prepare( "insert into " + qtest_prepare + " (id, name) values (?, 'Bart')" ) ); q.bindValue( 0, 99 ); QVERIFY_SQL( q, exec() ); q.addBindValue( 100 ); QVERIFY_SQL( q, exec() ); - QVERIFY( q.exec( "select * from " + qTableName( "qtest_prepare" ) + " where id > 98 order by id" ) ); + QVERIFY( q.exec( "select * from " + qtest_prepare + " where id > 98 order by id" ) ); for ( i = 99; i <= 100; ++i ) { QVERIFY( q.next() ); @@ -1815,7 +1830,7 @@ void tst_QSqlQuery::prepare_bind_exec() } /* insert a duplicate id and make sure the db bails out */ - QVERIFY( q.prepare( "insert into " + qTableName( "qtest_prepare" ) + " (id, name) values (?, ?)" ) ); + QVERIFY( q.prepare( "insert into " + qtest_prepare + " (id, name) values (?, ?)" ) ); q.addBindValue( 99 ); @@ -1837,7 +1852,7 @@ void tst_QSqlQuery::prepared_select() CHECK_DATABASE( db ); QSqlQuery q( db ); - QVERIFY_SQL( q, prepare( "select a.id, a.t_char, a.t_varchar from " + qTableName( "qtest" ) + " a where a.id = ?" ) ); + QVERIFY_SQL( q, prepare( "select a.id, a.t_char, a.t_varchar from " + qtest + " a where a.id = ?" ) ); q.bindValue( 0, 1 ); QVERIFY_SQL( q, exec() ); @@ -1857,7 +1872,7 @@ void tst_QSqlQuery::prepared_select() QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).toInt(), 3 ); - QVERIFY_SQL( q, prepare( "select a.id, a.t_char, a.t_varchar from " + qTableName( "qtest" ) + " a where a.id = ?" ) ); + QVERIFY_SQL( q, prepare( "select a.id, a.t_char, a.t_varchar from " + qtest + " a where a.id = ?" ) ); QCOMPARE( q.at(), ( int )QSql::BeforeFirstRow ); QVERIFY( !q.first() ); } @@ -1873,9 +1888,9 @@ void tst_QSqlQuery::sqlServerLongStrings() QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "CREATE TABLE " + qTableName( "qtest_longstr" ) + " (id int primary key, longstring ntext)" ) ); + QVERIFY_SQL( q, exec( "CREATE TABLE " + qTableName( "qtest_longstr", __FILE__ ) + " (id int primary key, longstring ntext)" ) ); - QVERIFY_SQL( q, prepare( "INSERT INTO " + qTableName( "qtest_longstr" ) + " VALUES (?, ?)" ) ); + QVERIFY_SQL( q, prepare( "INSERT INTO " + qTableName( "qtest_longstr", __FILE__ ) + " VALUES (?, ?)" ) ); q.addBindValue( 0 ); @@ -1893,7 +1908,7 @@ void tst_QSqlQuery::sqlServerLongStrings() QVERIFY_SQL( q, exec() ); - QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest_longstr" ) ) ); + QVERIFY_SQL( q, exec( "select * from " + qTableName( "qtest_longstr", __FILE__ ) ) ); QVERIFY_SQL( q, next() ); @@ -1957,7 +1972,7 @@ void tst_QSqlQuery::batchExec() QSKIP( "Database can't do BatchOperations", SkipSingle ); QSqlQuery q( db ); - QString tableName = qTableName( "qtest_batch" ); + const QString tableName = qTableName( "qtest_batch", __FILE__ ); QVERIFY_SQL( q, exec( "create table " + tableName + " (id int, name varchar(20), dt date, num numeric(8, 4))" ) ); QVERIFY_SQL( q, prepare( "insert into " + tableName + " (id, name, dt, num) values (?, ?, ?, ?)" ) ); @@ -2101,9 +2116,9 @@ void tst_QSqlQuery::record_sqlite() QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table "+qTableName( "record_sqlite" )+"(id integer primary key, name varchar, title int)" ) ); + QVERIFY_SQL( q, exec( "create table "+qTableName( "record_sqlite", __FILE__ )+"(id integer primary key, name varchar, title int)" ) ); - QSqlRecord rec = db.record( qTableName( "record_sqlite" ) ); + QSqlRecord rec = db.record( qTableName( "record_sqlite", __FILE__ ) ); QCOMPARE( rec.count(), 3 ); QCOMPARE( rec.field( 0 ).type(), QVariant::Int ); @@ -2111,7 +2126,7 @@ void tst_QSqlQuery::record_sqlite() QCOMPARE( rec.field( 2 ).type(), QVariant::Int ); /* important - select from an empty table */ - QVERIFY_SQL( q, exec( "select id, name, title from "+qTableName( "record_sqlite" ) ) ); + QVERIFY_SQL( q, exec( "select id, name, title from "+qTableName( "record_sqlite", __FILE__ ) ) ); rec = q.record(); QCOMPARE( rec.count(), 3 ); @@ -2130,13 +2145,13 @@ void tst_QSqlQuery::oraLong() QString aLotOfText( 127000, QLatin1Char( 'H' ) ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_longstr" ) + " (id int primary key, astr long)" ) ); - QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_longstr" ) + " (id, astr) values (?, ?)" ) ); + QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_longstr", __FILE__ ) + " (id int primary key, astr long)" ) ); + QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_longstr", __FILE__ ) + " (id, astr) values (?, ?)" ) ); q.addBindValue( 1 ); q.addBindValue( aLotOfText ); QVERIFY_SQL( q, exec() ); - QVERIFY_SQL( q, exec( "select id,astr from " + qTableName( "qtest_longstr" ) ) ); + QVERIFY_SQL( q, exec( "select id,astr from " + qTableName( "qtest_longstr", __FILE__ ) ) ); QVERIFY( q.next() ); QCOMPARE( q.value( 0 ).toInt(), 1 ); @@ -2151,8 +2166,8 @@ void tst_QSqlQuery::execErrorRecovery() QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_exerr" ) + " (id int not null primary key)" ) ); - QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_exerr" ) + " values (?)" ) ); + QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_exerr", __FILE__ ) + " (id int not null primary key)" ) ); + QVERIFY_SQL( q, prepare( "insert into " + qTableName( "qtest_exerr", __FILE__ ) + " values (?)" ) ); q.addBindValue( 1 ); QVERIFY_SQL( q, exec() ); @@ -2175,7 +2190,7 @@ void tst_QSqlQuery::lastInsertId() QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "qtest" ) + " values (41, 'VarChar41', 'Char41')" ) ); + QVERIFY_SQL( q, exec( "insert into " + qtest + " values (41, 'VarChar41', 'Char41')" ) ); QVariant v = q.lastInsertId(); @@ -2189,7 +2204,7 @@ void tst_QSqlQuery::lastQuery() CHECK_DATABASE( db ); QSqlQuery q( db ); - QString sql = "select * from " + qTableName( "qtest" ); + QString sql = "select * from " + qtest; QVERIFY_SQL( q, exec( sql ) ); QCOMPARE( q.lastQuery(), sql ); QCOMPARE( q.executedQuery(), sql ); @@ -2208,7 +2223,7 @@ void tst_QSqlQuery::bindWithDoubleColonCastOperator() return; } - QString tablename = qTableName( "bindtest" ); + const QString tablename(qTableName( "bindtest", __FILE__ )); QSqlQuery q( db ); @@ -2282,7 +2297,7 @@ void tst_QSqlQuery::createQueryOnClosedDatabase() QSqlQuery q( db ); db.open(); - QVERIFY_SQL( q, exec( QString( "select * from %1 where id = 1" ).arg( qTableName( "qtest" ) ) ) ); + QVERIFY_SQL( q, exec( QString( "select * from %1 where id = 1" ).arg( qtest ) ) ); QVERIFY_SQL( q, next() ); QCOMPARE( q.value( 0 ).toInt(), 1 ); @@ -2290,7 +2305,7 @@ void tst_QSqlQuery::createQueryOnClosedDatabase() QCOMPARE( q.value( 2 ).toString().trimmed(), QLatin1String( "Char1" ) ); db.close(); - QVERIFY2( !q.exec( QString( "select * from %1 where id = 1" ).arg( qTableName( "qtest" ) ) ), + QVERIFY2( !q.exec( QString( "select * from %1 where id = 1" ).arg( qtest ) ), qPrintable( QString( "This can't happen! The query should not have been executed!" ) ) ); } @@ -2303,7 +2318,7 @@ void tst_QSqlQuery::reExecutePreparedForwardOnlyQuery() QSqlQuery q( db ); q.setForwardOnly( true ); - QVERIFY_SQL( q, prepare( QString( "SELECT id, t_varchar, t_char FROM %1 WHERE id = :id" ).arg( qTableName( "qtest" ) ) ) ); + QVERIFY_SQL( q, prepare( QString( "SELECT id, t_varchar, t_char FROM %1 WHERE id = :id" ).arg( qtest ) ) ); q.bindValue( ":id", 1 ); QVERIFY_SQL( q, exec() ); @@ -2328,7 +2343,7 @@ void tst_QSqlQuery::finish() CHECK_DATABASE( db ); QSqlQuery q( db ); - QVERIFY_SQL( q, prepare( "SELECT id FROM " + qTableName( "qtest" ) + " WHERE id = ?" ) ); + QVERIFY_SQL( q, prepare( "SELECT id FROM " + qtest + " WHERE id = ?" ) ); int id = 4; q.bindValue( 0, id ); @@ -2349,7 +2364,7 @@ void tst_QSqlQuery::finish() q.finish(); QVERIFY( !q.isActive() ); - QVERIFY_SQL( q, exec( "SELECT id FROM " + qTableName( "qtest" ) + " WHERE id = 1" ) ); + QVERIFY_SQL( q, exec( "SELECT id FROM " + qtest + " WHERE id = 1" ) ); QVERIFY( q.isActive() ); QVERIFY_SQL( q, next() ); QCOMPARE( q.value( 0 ).toInt(), 1 ); @@ -2374,7 +2389,7 @@ void tst_QSqlQuery::sqlite_finish() db2.setDatabaseName( db.databaseName() ); QVERIFY_SQL( db2, open() ); - QString tableName = qTableName( "qtest_lockedtable" ); + const QString tableName(qTableName( "qtest_lockedtable", __FILE__ )); QSqlQuery q( db ); tst_Databases::safeDropTable( db, tableName ); @@ -2424,7 +2439,7 @@ void tst_QSqlQuery::nextResult() else if ( db.driverName().startsWith( "QDB2" ) ) driverType = DB2; - QString tableName = qTableName( "more_results" ); + const QString tableName(qTableName( "more_results", __FILE__ )); QVERIFY_SQL( q, exec( "CREATE TABLE " + tableName + " (id integer, text varchar(20), num numeric(6, 3), empty varchar(10));" ) ); @@ -2528,7 +2543,7 @@ void tst_QSqlQuery::nextResult() } // Stored procedure with multiple result sets - QString procName = qTableName( "proc_more_res" ); + const QString procName(qTableName( "proc_more_res", __FILE__ )); q.exec( QString( "DROP PROCEDURE %1;" ).arg( procName ) ); @@ -2606,7 +2621,7 @@ void tst_QSqlQuery::blobsPreparedQuery() if ( !db.driver()->hasFeature( QSqlDriver::BLOB ) || !db.driver()->hasFeature( QSqlDriver::PreparedQueries ) ) QSKIP( "DBMS does not support BLOBs or prepared queries", SkipSingle ); - QString tableName = qTableName( "blobstest" ); + const QString tableName(qTableName( "blobstest", __FILE__ )); QSqlQuery q( db ); q.setForwardOnly( true ); // This is needed to make the test work with DB2. @@ -2661,8 +2676,8 @@ void tst_QSqlQuery::emptyTableNavigate() { QSqlQuery q( db ); - QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_empty" ) + " (id char(10))" ) ); - QVERIFY_SQL( q, prepare( "select * from " + qTableName( "qtest_empty" ) ) ); + QVERIFY_SQL( q, exec( "create table " + qTableName( "qtest_empty", __FILE__ ) + " (id char(10))" ) ); + QVERIFY_SQL( q, prepare( "select * from " + qTableName( "qtest_empty", __FILE__ ) ) ); QVERIFY_SQL( q, exec() ); QVERIFY( !q.next() ); QCOMPARE( q.lastError().isValid(), false ); @@ -2675,19 +2690,20 @@ void tst_QSqlQuery::task_217003() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); QSqlQuery q( db ); + const QString Planet(qTableName( "Planet", __FILE__)); - QVERIFY_SQL( q, exec( "create table " + qTableName( "Planet" ) + " (Name varchar(20))" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "Planet" ) + " VALUES ('Mercury')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "Planet" ) + " VALUES ('Venus')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "Planet" ) + " VALUES ('Earth')" ) ); - QVERIFY_SQL( q, exec( "insert into " + qTableName( "Planet" ) + " VALUES ('Mars')" ) ); + QVERIFY_SQL( q, exec( "create table " + Planet + " (Name varchar(20))" ) ); + QVERIFY_SQL( q, exec( "insert into " + Planet + " VALUES ('Mercury')" ) ); + QVERIFY_SQL( q, exec( "insert into " + Planet + " VALUES ('Venus')" ) ); + QVERIFY_SQL( q, exec( "insert into " + Planet + " VALUES ('Earth')" ) ); + QVERIFY_SQL( q, exec( "insert into " + Planet + " VALUES ('Mars')" ) ); - QVERIFY_SQL( q, exec( "SELECT Name FROM "+qTableName( "Planet" ) ) ); + QVERIFY_SQL( q, exec( "SELECT Name FROM " + Planet ) ); QVERIFY_SQL( q, seek( 3 ) ); QCOMPARE( q.value( 0 ).toString(), QString( "Mars" ) ); QVERIFY_SQL( q, seek( 1 ) ); QCOMPARE( q.value( 0 ).toString(), QString( "Venus" ) ); - QVERIFY_SQL( q, exec( "SELECT Name FROM "+qTableName( "Planet" ) ) ); + QVERIFY_SQL( q, exec( "SELECT Name FROM " + Planet ) ); QVERIFY_SQL( q, seek( 3 ) ); QCOMPARE( q.value( 0 ).toString(), QString( "Mars" ) ); QVERIFY_SQL( q, seek( 0 ) ); @@ -2704,7 +2720,7 @@ void tst_QSqlQuery::task_250026() CHECK_DATABASE( db ); QSqlQuery q( db ); - QString tableName = qTableName( "task_250026" ); + const QString tableName(qTableName( "task_250026", __FILE__ )); if ( !q.exec( "create table " + tableName + " (longfield varchar(1100))" ) ) { qDebug() << "Error" << q.lastError(); @@ -2752,7 +2768,7 @@ void tst_QSqlQuery::task_229811() QSqlQuery q( db ); - QString tableName = qTableName( "task_229811" ); + const QString tableName(qTableName( "task_229811", __FILE__ )); if ( !q.exec( "CREATE TABLE " + tableName + " (Word varchar(20))" ) ) { qDebug() << "Warning" << q.lastError(); @@ -2799,7 +2815,7 @@ void tst_QSqlQuery::task_234422() m_airlines << "Lufthansa" << "SAS" << "United" << "KLM" << "Aeroflot"; m_countries << "DE" << "SE" << "US" << "NL" << "RU"; - QString tableName = qTableName( "task_234422" ); + const QString tableName(qTableName( "task_234422", __FILE__ )); QVERIFY_SQL(query,exec("CREATE TABLE " + tableName + " (id int primary key, " "name varchar(20), homecountry varchar(2))")); @@ -2831,7 +2847,7 @@ void tst_QSqlQuery::task_233829() CHECK_DATABASE( db ); QSqlQuery q( db ); - QString tableName = qTableName("task_233829"); + const QString tableName(qTableName("task_233829", __FILE__)); QVERIFY_SQL(q,exec("CREATE TABLE " + tableName + "(dbl1 double precision,dbl2 double precision) without oids;")); QString queryString("INSERT INTO " + tableName +"(dbl1, dbl2) VALUES(?,?)"); @@ -2851,7 +2867,7 @@ void tst_QSqlQuery::sqlServerReturn0() if (!tst_Databases::isSqlServer( db )) QSKIP("SQL Server specific test", SkipSingle); - QString tableName(qTableName("test141895")), procName(qTableName("test141895_proc")); + const QString tableName(qTableName("test141895", __FILE__)), procName(qTableName("test141895_proc", __FILE__)); QSqlQuery q( db ); q.exec("DROP TABLE " + tableName); q.exec("DROP PROCEDURE " + procName); @@ -2877,7 +2893,7 @@ void tst_QSqlQuery::QTBUG_551() QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); QSqlQuery q(db); - QString pkgname=qTableName("pkg"); + const QString pkgname(qTableName("pkg", __FILE__)); QVERIFY_SQL(q, exec("CREATE OR REPLACE PACKAGE "+pkgname+" IS \n\ \n\ TYPE IntType IS TABLE OF INTEGER INDEX BY BINARY_INTEGER;\n\ @@ -2923,17 +2939,18 @@ void tst_QSqlQuery::QTBUG_5251() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QString timetest(qTableName("timetest", __FILE__)); if (!db.driverName().startsWith( "QPSQL" )) return; QSqlQuery q(db); - q.exec("DROP TABLE " + qTableName("timetest")); - QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("timetest") + " (t TIME)")); - QVERIFY_SQL(q, exec("INSERT INTO " + qTableName("timetest") + " VALUES ('1:2:3.666')")); + q.exec("DROP TABLE " + timetest); + QVERIFY_SQL(q, exec("CREATE TABLE " + timetest + " (t TIME)")); + QVERIFY_SQL(q, exec("INSERT INTO " + timetest + " VALUES ('1:2:3.666')")); QSqlTableModel timetestModel(0,db); timetestModel.setEditStrategy(QSqlTableModel::OnManualSubmit); - timetestModel.setTable(qTableName("timetest")); + timetestModel.setTable(timetest); QVERIFY_SQL(timetestModel, select()); QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("01:02:03.666")); @@ -2942,7 +2959,7 @@ void tst_QSqlQuery::QTBUG_5251() QVERIFY_SQL(timetestModel, submitAll()); QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:12:34.500")); - QVERIFY_SQL(q, exec("UPDATE " + qTableName("timetest") + " SET t = '0:11:22.33'")); + QVERIFY_SQL(q, exec("UPDATE " + timetest + " SET t = '0:11:22.33'")); QVERIFY_SQL(timetestModel, select()); QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:11:22.330")); @@ -2955,7 +2972,7 @@ void tst_QSqlQuery::QTBUG_6421() CHECK_DATABASE( db ); QSqlQuery q(db); - QString tableName=qTableName(QLatin1String("bug6421")).toUpper(); + const QString tableName(qTableName("bug6421", __FILE__).toUpper()); QVERIFY_SQL(q, exec("create table "+tableName+"(COL1 char(10), COL2 char(10), COL3 char(10))")); QVERIFY_SQL(q, exec("create index INDEX1 on "+tableName+" (COL1 desc)")); @@ -2980,16 +2997,16 @@ void tst_QSqlQuery::QTBUG_6618() QSKIP("SQL Server specific test", SkipSingle); QSqlQuery q(db); - q.exec( "drop procedure " + qTableName( "tst_raiseError" ) ); //non-fatal + q.exec( "drop procedure " + qTableName( "tst_raiseError", __FILE__ ) ); //non-fatal QString errorString; for (int i=0;i<110;i++) errorString+="reallylong"; errorString+=" error"; - QVERIFY_SQL( q, exec("create procedure " + qTableName( "tst_raiseError" ) + " as\n" + QVERIFY_SQL( q, exec("create procedure " + qTableName( "tst_raiseError", __FILE__ ) + " as\n" "begin\n" " raiserror('" + errorString + "', 16, 1)\n" "end\n" )); - q.exec( "{call " + qTableName( "tst_raiseError" ) + "}" ); + q.exec( "{call " + qTableName( "tst_raiseError", __FILE__ ) + "}" ); QVERIFY(q.lastError().text().contains(errorString)); } @@ -3002,7 +3019,7 @@ void tst_QSqlQuery::QTBUG_6852() QSKIP( "Test requires MySQL >= 5.0", SkipSingle ); QSqlQuery q(db); - QString tableName(qTableName(QLatin1String("bug6852"))), procName(qTableName(QLatin1String("bug6852_proc"))); + const QString tableName(qTableName("bug6852", __FILE__)), procName(qTableName("bug6852_proc", __FILE__)); QVERIFY_SQL(q, exec("DROP PROCEDURE IF EXISTS "+procName)); QVERIFY_SQL(q, exec("CREATE TABLE "+tableName+"(\n" @@ -3036,7 +3053,7 @@ void tst_QSqlQuery::QTBUG_5765() QSKIP( "Test requires MySQL >= 4.1", SkipSingle ); QSqlQuery q(db); - QString tableName(qTableName(QLatin1String("bug5765"))); + const QString tableName(qTableName("bug5765", __FILE__)); QVERIFY_SQL(q, exec("CREATE TABLE "+tableName+"(testval TINYINT(1) DEFAULT 0)")); q.prepare("INSERT INTO "+tableName+" SET testval = :VALUE"); @@ -3074,7 +3091,7 @@ void tst_QSqlQuery::benchmark() QSKIP( "Test requires MySQL >= 5.0", SkipSingle ); QSqlQuery q(db); - QString tableName(qTableName(QLatin1String("benchmark"))); + const QString tableName(qTableName("benchmark", __FILE__)); tst_Databases::safeDropTable( db, tableName ); diff --git a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp index 7e75d28..b64d599 100644 --- a/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp +++ b/tests/auto/qsqlquerymodel/tst_qsqlquerymodel.cpp @@ -148,10 +148,10 @@ void tst_QSqlQueryModel::cleanupTestCase() void tst_QSqlQueryModel::dropTestTables(QSqlDatabase db) { QStringList tableNames; - tableNames << qTableName("test") - << qTableName("test2") - << qTableName("test3") - << qTableName("many"); + tableNames << qTableName("test", __FILE__) + << qTableName("test2", __FILE__) + << qTableName("test3", __FILE__) + << qTableName("many", __FILE__); tst_Databases::safeDropTables(db, tableNames); } @@ -161,10 +161,10 @@ void tst_QSqlQueryModel::createTestTables(QSqlDatabase db) QSqlQuery q(db); if(tst_Databases::isPostgreSQL(db)) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); - QVERIFY_SQL( q, exec("create table " + qTableName("test") + "(id integer not null, name varchar(20), title integer, primary key (id))")); - QVERIFY_SQL( q, exec("create table " + qTableName("test2") + "(id integer not null, title varchar(20), primary key (id))")); - QVERIFY_SQL( q, exec("create table " + qTableName("test3") + "(id integer not null, primary key (id))")); - QVERIFY_SQL( q, exec("create table " + qTableName("many") + "(id integer not null, name varchar(20), primary key (id))")); + QVERIFY_SQL( q, exec("create table " + qTableName("test", __FILE__) + "(id integer not null, name varchar(20), title integer, primary key (id))")); + QVERIFY_SQL( q, exec("create table " + qTableName("test2", __FILE__) + "(id integer not null, title varchar(20), primary key (id))")); + QVERIFY_SQL( q, exec("create table " + qTableName("test3", __FILE__) + "(id integer not null, primary key (id))")); + QVERIFY_SQL( q, exec("create table " + qTableName("many", __FILE__) + "(id integer not null, name varchar(20), primary key (id))")); } void tst_QSqlQueryModel::populateTestTables(QSqlDatabase db) @@ -174,38 +174,38 @@ void tst_QSqlQueryModel::populateTestTables(QSqlDatabase db) QSqlQuery q(db), q2(db); - tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp") << qTableName("test3tmp")); - QVERIFY_SQL(q, exec("create table " + qTableName("manytmp") + "(id integer not null, name varchar(20), primary key (id))")); - QVERIFY_SQL(q, exec("create table " + qTableName("test3tmp") + "(id integer not null, primary key (id))")); + tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp", __FILE__) << qTableName("test3tmp", __FILE__)); + QVERIFY_SQL(q, exec("create table " + qTableName("manytmp", __FILE__) + "(id integer not null, name varchar(20), primary key (id))")); + QVERIFY_SQL(q, exec("create table " + qTableName("test3tmp", __FILE__) + "(id integer not null, primary key (id))")); if (hasTransactions) QVERIFY_SQL(db, transaction()); - QVERIFY_SQL(q, exec("insert into " + qTableName("test") + " values(1, 'harry', 1)")); - QVERIFY_SQL(q, exec("insert into " + qTableName("test") + " values(2, 'trond', 2)")); - QVERIFY_SQL(q, exec("insert into " + qTableName("test2") + " values(1, 'herr')")); - QVERIFY_SQL(q, exec("insert into " + qTableName("test2") + " values(2, 'mister')")); + QVERIFY_SQL(q, exec("insert into " + qTableName("test", __FILE__) + " values(1, 'harry', 1)")); + QVERIFY_SQL(q, exec("insert into " + qTableName("test", __FILE__) + " values(2, 'trond', 2)")); + QVERIFY_SQL(q, exec("insert into " + qTableName("test2", __FILE__) + " values(1, 'herr')")); + QVERIFY_SQL(q, exec("insert into " + qTableName("test2", __FILE__) + " values(2, 'mister')")); - QVERIFY_SQL(q, exec(QString("insert into " + qTableName("test3") + " values(0)"))); - QVERIFY_SQL(q, prepare("insert into "+qTableName("test3")+"(id) select id + ? from "+qTableName("test3tmp"))); + QVERIFY_SQL(q, exec(QString("insert into " + qTableName("test3", __FILE__) + " values(0)"))); + QVERIFY_SQL(q, prepare("insert into "+qTableName("test3", __FILE__)+"(id) select id + ? from "+qTableName("test3tmp", __FILE__))); for (int i=1; i<260; i*=2) { - q2.exec("delete from "+qTableName("test3tmp")); - QVERIFY_SQL(q2, exec("insert into "+qTableName("test3tmp")+"(id) select id from "+qTableName("test3"))); + q2.exec("delete from "+qTableName("test3tmp", __FILE__)); + QVERIFY_SQL(q2, exec("insert into "+qTableName("test3tmp", __FILE__)+"(id) select id from "+qTableName("test3", __FILE__))); q.bindValue(0, i); QVERIFY_SQL(q, exec()); } - QVERIFY_SQL(q, exec(QString("insert into " + qTableName("many") + "(id, name) values (0, \'harry\')"))); - QVERIFY_SQL(q, prepare("insert into "+qTableName("many")+"(id, name) select id + ?, name from "+qTableName("manytmp"))); + QVERIFY_SQL(q, exec(QString("insert into " + qTableName("many", __FILE__) + "(id, name) values (0, \'harry\')"))); + QVERIFY_SQL(q, prepare("insert into "+qTableName("many", __FILE__)+"(id, name) select id + ?, name from "+qTableName("manytmp", __FILE__))); for (int i=1; i < 2048; i*=2) { - q2.exec("delete from "+qTableName("manytmp")); - QVERIFY_SQL(q2, exec("insert into "+qTableName("manytmp")+"(id, name) select id, name from "+qTableName("many"))); + q2.exec("delete from "+qTableName("manytmp", __FILE__)); + QVERIFY_SQL(q2, exec("insert into "+qTableName("manytmp", __FILE__)+"(id, name) select id, name from "+qTableName("many", __FILE__))); q.bindValue(0, i); QVERIFY_SQL(q, exec()); } if (hasTransactions) QVERIFY_SQL(db, commit()); - tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp") << qTableName("test3tmp")); + tst_Databases::safeDropTables(db, QStringList() << qTableName("manytmp", __FILE__) << qTableName("test3tmp", __FILE__)); } void tst_QSqlQueryModel::generic_data(const QString& engine) @@ -233,7 +233,7 @@ void tst_QSqlQueryModel::removeColumn() CHECK_DATABASE(db); DBTestModel model; - model.setQuery(QSqlQuery("select * from " + qTableName("test"), db)); + model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__), db)); model.fetchMore(); QSignalSpy spy(&model, SIGNAL(columnsAboutToBeRemoved(QModelIndex, int, int))); @@ -315,7 +315,7 @@ void tst_QSqlQueryModel::insertColumn() CHECK_DATABASE(db); DBTestModel model; - model.setQuery(QSqlQuery("select * from " + qTableName("test"), db)); + model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__), db)); model.fetchMore(); // necessary??? QSignalSpy spy(&model, SIGNAL(columnsInserted(QModelIndex, int, int))); @@ -395,7 +395,7 @@ void tst_QSqlQueryModel::record() CHECK_DATABASE(db); QSqlQueryModel model; - model.setQuery(QSqlQuery("select * from " + qTableName("test"), db)); + model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__), db)); QSqlRecord rec = model.record(); @@ -429,7 +429,7 @@ void tst_QSqlQueryModel::setHeaderData() QVERIFY(!model.setHeaderData(5, Qt::Vertical, "foo")); QVERIFY(model.headerData(5, Qt::Vertical).isValid()); - model.setQuery(QSqlQuery("select * from " + qTableName("test"), db)); + model.setQuery(QSqlQuery("select * from " + qTableName("test", __FILE__), db)); qRegisterMetaType<Qt::Orientation>("Qt::Orientation"); QSignalSpy spy(&model, SIGNAL(headerDataChanged(Qt::Orientation, int, int))); @@ -459,7 +459,7 @@ void tst_QSqlQueryModel::fetchMore() QSqlQueryModel model; QSignalSpy spy(&model, SIGNAL(rowsInserted(QModelIndex, int, int))); - model.setQuery(QSqlQuery("select * from " + qTableName("many"), db)); + model.setQuery(QSqlQuery("select * from " + qTableName("many", __FILE__), db)); int rowCount = model.rowCount(); QCOMPARE(spy.value(0).value(1).toInt(), 0); @@ -491,7 +491,7 @@ void tst_QSqlQueryModel::withSortFilterProxyModel() QSKIP("Test applies only for drivers not reporting the query size.", SkipSingle); QSqlQueryModel model; - model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test3"), db)); + model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test3", __FILE__), db)); QSortFilterProxyModel proxy; proxy.setSourceModel(&model); @@ -500,7 +500,7 @@ void tst_QSqlQueryModel::withSortFilterProxyModel() QSignalSpy modelRowsRemovedSpy(&model, SIGNAL(rowsRemoved(const QModelIndex &, int, int))); QSignalSpy modelRowsInsertedSpy(&model, SIGNAL(rowsInserted(const QModelIndex &, int, int))); - model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test3"), db)); + model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test3", __FILE__), db)); view.scrollToBottom(); QTestEventLoop::instance().enterLoop(1); @@ -536,12 +536,12 @@ void tst_QSqlQueryModel::setQuerySignalEmission() QSignalSpy modelRowsRemovedSpy(&model, SIGNAL(rowsRemoved(const QModelIndex &, int, int))); // First select, the model was empty and no rows had to be removed! - model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test"), db)); + model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__), db)); QCOMPARE(modelRowsAboutToBeRemovedSpy.count(), 0); QCOMPARE(modelRowsRemovedSpy.count(), 0); // Second select, the model wasn't empty and two rows had to be removed! - model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test"), db)); + model.setQuery(QSqlQuery("SELECT * FROM " + qTableName("test", __FILE__), db)); QCOMPARE(modelRowsAboutToBeRemovedSpy.count(), 1); QCOMPARE(modelRowsAboutToBeRemovedSpy.value(0).value(1).toInt(), 0); QCOMPARE(modelRowsAboutToBeRemovedSpy.value(0).value(2).toInt(), 1); @@ -564,7 +564,7 @@ void tst_QSqlQueryModel::setQueryWithNoRowsInResultSet() // The query's result set will be empty so no signals should be emitted! QSqlQuery query(db); - QVERIFY_SQL(query, exec("SELECT * FROM " + qTableName("test") + " where 0 = 1")); + QVERIFY_SQL(query, exec("SELECT * FROM " + qTableName("test", __FILE__) + " where 0 = 1")); model.setQuery(query); QCOMPARE(modelRowsAboutToBeInsertedSpy.count(), 0); QCOMPARE(modelRowsInsertedSpy.count(), 0); @@ -578,13 +578,14 @@ void tst_QSqlQueryModel::task_180617() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); + const QString test3(qTableName("test3", __FILE__)); QTableView view; QCOMPARE(view.columnAt(0), -1); QCOMPARE(view.rowAt(0), -1); QSqlQueryModel model; - model.setQuery( "SELECT TOP 0 * FROM " + qTableName("test3"), db ); + model.setQuery( "SELECT TOP 0 * FROM " + test3, db ); view.setModel(&model); bool error = false; @@ -595,10 +596,10 @@ void tst_QSqlQueryModel::task_180617() QCOMPARE(view.columnAt(0), (error)?-1:0 ); QCOMPARE(view.rowAt(0), -1); - model.setQuery( "SELECT TOP 0 * FROM " + qTableName("test3"), db ); - model.setQuery( "SELECT TOP 0 * FROM " + qTableName("test3"), db ); - model.setQuery( "SELECT TOP 0 * FROM " + qTableName("test3"), db ); - model.setQuery( "SELECT TOP 0 * FROM " + qTableName("test3"), db ); + model.setQuery( "SELECT TOP 0 * FROM " + test3, db ); + model.setQuery( "SELECT TOP 0 * FROM " + test3, db ); + model.setQuery( "SELECT TOP 0 * FROM " + test3, db ); + model.setQuery( "SELECT TOP 0 * FROM " + test3, db ); QCOMPARE(view.columnAt(0), (error)?-1:0 ); QCOMPARE(view.rowAt(0), -1); diff --git a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp index eab1364..c4bd540 100644 --- a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp +++ b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp @@ -45,6 +45,11 @@ #include "../qsqldatabase/tst_databases.h" +const QString reltest1(qTableName("reltest1", __FILE__)), + reltest2(qTableName("reltest2", __FILE__)), + reltest3(qTableName("reltest3", __FILE__)), + reltest4(qTableName("reltest4", __FILE__)), + reltest5(qTableName("reltest5", __FILE__)); //TESTED_CLASS= @@ -107,37 +112,37 @@ void tst_QSqlRelationalTableModel::recreateTestTables(QSqlDatabase db) dropTestTables(db); QSqlQuery q(db); - QVERIFY_SQL( q, exec("create table " + qTableName("reltest1") + + QVERIFY_SQL( q, exec("create table " + reltest1 + " (id int not null primary key, name varchar(20), title_key int, another_title_key int)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest1") + " values(1, 'harry', 1, 2)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest1") + " values(2, 'trond', 2, 1)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest1") + " values(3, 'vohi', 1, 2)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest1") + " values(4, 'boris', 2, 2)")); + QVERIFY_SQL( q, exec("insert into " + reltest1 + " values(1, 'harry', 1, 2)")); + QVERIFY_SQL( q, exec("insert into " + reltest1 + " values(2, 'trond', 2, 1)")); + QVERIFY_SQL( q, exec("insert into " + reltest1 + " values(3, 'vohi', 1, 2)")); + QVERIFY_SQL( q, exec("insert into " + reltest1 + " values(4, 'boris', 2, 2)")); - QVERIFY_SQL( q, exec("create table " + qTableName("reltest2") + " (tid int not null primary key, title varchar(20))")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest2") + " values(1, 'herr')")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest2") + " values(2, 'mister')")); + QVERIFY_SQL( q, exec("create table " + reltest2 + " (tid int not null primary key, title varchar(20))")); + QVERIFY_SQL( q, exec("insert into " + reltest2 + " values(1, 'herr')")); + QVERIFY_SQL( q, exec("insert into " + reltest2 + " values(2, 'mister')")); - QVERIFY_SQL( q, exec("create table " + qTableName("reltest3") + " (id int not null primary key, name varchar(20), city_key int)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest3") + " values(1, 'Gustav', 1)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest3") + " values(2, 'Heidi', 2)")); + QVERIFY_SQL( q, exec("create table " + reltest3 + " (id int not null primary key, name varchar(20), city_key int)")); + QVERIFY_SQL( q, exec("insert into " + reltest3 + " values(1, 'Gustav', 1)")); + QVERIFY_SQL( q, exec("insert into " + reltest3 + " values(2, 'Heidi', 2)")); - QVERIFY_SQL( q, exec("create table " + qTableName("reltest4") + " (id int not null primary key, name varchar(20))")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest4") + " values(1, 'Oslo')")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest4") + " values(2, 'Trondheim')")); + QVERIFY_SQL( q, exec("create table " + reltest4 + " (id int not null primary key, name varchar(20))")); + QVERIFY_SQL( q, exec("insert into " + reltest4 + " values(1, 'Oslo')")); + QVERIFY_SQL( q, exec("insert into " + reltest4 + " values(2, 'Trondheim')")); - QVERIFY_SQL( q, exec("create table " + qTableName("reltest5") + " (title varchar(20) not null primary key, abbrev varchar(20))")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest5") + " values('herr', 'Hr')")); - QVERIFY_SQL( q, exec("insert into " + qTableName("reltest5") + " values('mister', 'Mr')")); + QVERIFY_SQL( q, exec("create table " + reltest5 + " (title varchar(20) not null primary key, abbrev varchar(20))")); + QVERIFY_SQL( q, exec("insert into " + reltest5 + " values('herr', 'Hr')")); + QVERIFY_SQL( q, exec("insert into " + reltest5 + " values('mister', 'Mr')")); if (testWhiteSpaceNames(db.driverName())) { - QString reltest6 = db.driver()->escapeIdentifier(qTableName("rel test6"), QSqlDriver::TableName); + QString reltest6 = db.driver()->escapeIdentifier(qTableName("rel", __FILE__)+" test6", QSqlDriver::TableName); QVERIFY_SQL( q, exec("create table " + reltest6 + " (id int not null primary key, " + db.driver()->escapeIdentifier("city key", QSqlDriver::FieldName) + " int, " + db.driver()->escapeIdentifier("extra field", QSqlDriver::FieldName) + " int)")); QVERIFY_SQL( q, exec("insert into " + reltest6 + " values(1, 1,9)")); QVERIFY_SQL( q, exec("insert into " + reltest6 + " values(2, 2,8)")); - QString reltest7 = db.driver()->escapeIdentifier(qTableName("rel test7"), QSqlDriver::TableName); + QString reltest7 = db.driver()->escapeIdentifier(qTableName("rel", __FILE__)+" test7", QSqlDriver::TableName); QVERIFY_SQL( q, exec("create table " + reltest7 + " (" + db.driver()->escapeIdentifier("city id", QSqlDriver::TableName) + " int not null primary key, " + db.driver()->escapeIdentifier("city name", QSqlDriver::FieldName) + " varchar(20))")); QVERIFY_SQL( q, exec("insert into " + reltest7 + " values(1, 'New York')")); QVERIFY_SQL( q, exec("insert into " + reltest7 + " values(2, 'Washington')")); @@ -173,19 +178,19 @@ void tst_QSqlRelationalTableModel::cleanupTestCase() void tst_QSqlRelationalTableModel::dropTestTables( QSqlDatabase db ) { QStringList tableNames; - tableNames << qTableName( "reltest1" ) - << qTableName( "reltest2" ) - << qTableName( "reltest3" ) - << qTableName( "reltest4" ) - << qTableName( "reltest5" ) - << qTableName( "rel test6" ) - << qTableName( "rel test7" ) - << qTableName("CASETEST1" ) - << qTableName("casetest1" ); + tableNames << reltest1 + << reltest2 + << reltest3 + << reltest4 + << reltest5 + << (qTableName( "rel", __FILE__)+" test6") + << (qTableName( "rel", __FILE__)+" test7") + << qTableName("CASETEST1", db.driver() ) + << qTableName("casetest1", db.driver() ); tst_Databases::safeDropTables( db, tableNames ); - db.exec("DROP SCHEMA "+qTableName("QTBUG_5373")+" CASCADE"); - db.exec("DROP SCHEMA "+qTableName("QTBUG_5373_s2")+" CASCADE"); + db.exec("DROP SCHEMA "+qTableName("QTBUG_5373", __FILE__)+" CASCADE"); + db.exec("DROP SCHEMA "+qTableName("QTBUG_5373_s2", __FILE__)+" CASCADE"); } void tst_QSqlRelationalTableModel::init() @@ -204,8 +209,8 @@ void tst_QSqlRelationalTableModel::data() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QCOMPARE(model.columnCount(), 4); @@ -219,8 +224,8 @@ void tst_QSqlRelationalTableModel::data() //check data retrieval when relational key is a non-integer type //in this case a string QSqlRelationalTableModel model2(0,db); - model2.setTable(qTableName("reltest2")); - model2.setRelation(1, QSqlRelation(qTableName("reltest5"),"title","abbrev")); + model2.setTable(reltest2); + model2.setRelation(1, QSqlRelation(reltest5,"title","abbrev")); QVERIFY_SQL(model2, select()); QCOMPARE(model2.data(model2.index(0, 1)).toString(), QString("Hr")); @@ -237,9 +242,9 @@ void tst_QSqlRelationalTableModel::setData() { QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); + model.setTable(reltest1); model.setSort(0, Qt::AscendingOrder); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QVERIFY(model.setData(model.index(0, 1), QString("harry2"))); @@ -260,7 +265,7 @@ void tst_QSqlRelationalTableModel::setData() } { //verify values QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); + model.setTable(reltest1); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -269,7 +274,7 @@ void tst_QSqlRelationalTableModel::setData() QCOMPARE(model.data(model.index(3, 1)).toString(), QString("boris2")); QCOMPARE(model.data(model.index(3, 2)).toInt(), 1); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(0, 2)).toString(), QString("mister")); QCOMPARE(model.data(model.index(3,2)).toString(), QString("herr")); @@ -279,10 +284,10 @@ void tst_QSqlRelationalTableModel::setData() //set the values using OnFieldChange strategy { QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); + model.setTable(reltest1); model.setEditStrategy(QSqlTableModel::OnFieldChange); model.setSort(0, Qt::AscendingOrder); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QVERIFY(model.setData(model.index(1,1), QString("trond2"))); @@ -293,14 +298,14 @@ void tst_QSqlRelationalTableModel::setData() } { //verify values QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); + model.setTable(reltest1); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(1, 1)).toString(), QString("trond2")); QCOMPARE(model.data(model.index(2, 2)).toInt(), 2); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(2, 2)).toString(), QString("mister")); } @@ -309,13 +314,13 @@ void tst_QSqlRelationalTableModel::setData() { QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); //sybase doesn't allow tables with the same alias used twice as col names //so don't set up an identical relation when using the tds driver if (!db.driverName().startsWith("QTDS")) - model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(3, QSqlRelation(reltest2, "tid", "title")); model.setEditStrategy(QSqlTableModel::OnManualSubmit); model.setSort(0, Qt::AscendingOrder); @@ -336,7 +341,7 @@ void tst_QSqlRelationalTableModel::setData() } { //verify values QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); + model.setTable(reltest1); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -344,9 +349,9 @@ void tst_QSqlRelationalTableModel::setData() QCOMPARE(model.data(model.index(3, 2)).toInt(), 1); QCOMPARE(model.data(model.index(0, 3)).toInt(), 1); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); if (!db.driverName().startsWith("QTDS")) - model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(3, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(3, 2)).toString(), QString("herr")); @@ -361,8 +366,8 @@ void tst_QSqlRelationalTableModel::setData() { QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest2")); - model.setRelation(1, QSqlRelation(qTableName("reltest5"), "title", "abbrev")); + model.setTable(reltest2); + model.setRelation(1, QSqlRelation(reltest5, "title", "abbrev")); model.setEditStrategy(QSqlTableModel::OnManualSubmit); QVERIFY_SQL(model, select()); @@ -385,9 +390,9 @@ void tst_QSqlRelationalTableModel::multipleRelation() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); - model.setRelation(3, QSqlRelation(qTableName("reltest4"), "id", "name")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); + model.setRelation(3, QSqlRelation(reltest4, "id", "name")); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -407,8 +412,8 @@ void tst_QSqlRelationalTableModel::insertRecord() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -449,8 +454,8 @@ void tst_QSqlRelationalTableModel::setRecord() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -502,12 +507,12 @@ void tst_QSqlRelationalTableModel::insertWithStrategies() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); model.setSort(0, Qt::AscendingOrder); if (!db.driverName().startsWith("QTDS")) - model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(3, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(0,0)).toInt(), 1); @@ -608,8 +613,8 @@ void tst_QSqlRelationalTableModel::removeColumn() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QVERIFY_SQL(model, removeColumn(3)); @@ -639,8 +644,8 @@ void tst_QSqlRelationalTableModel::filter() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); model.setFilter("title = 'herr'"); QVERIFY_SQL(model, select()); @@ -657,10 +662,10 @@ void tst_QSqlRelationalTableModel::sort() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); if (!db.driverName().startsWith("QTDS")) - model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(3, QSqlRelation(reltest2, "tid", "title")); model.setSort(2, Qt::DescendingOrder); QVERIFY_SQL(model, select()); @@ -755,9 +760,9 @@ void tst_QSqlRelationalTableModel::revert() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); - model.setRelation(3, QSqlRelation(qTableName("reltest4"), "id", "name")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); + model.setRelation(3, QSqlRelation(reltest4, "id", "name")); model.setSort(0, Qt::AscendingOrder); @@ -781,11 +786,11 @@ void tst_QSqlRelationalTableModel::clearDisplayValuesCache() QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); if (!db.driverName().startsWith("QTDS")) - model.setRelation(3, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(3, QSqlRelation(reltest2, "tid", "title")); model.setSort(1, Qt::AscendingOrder); model.setEditStrategy(QSqlTableModel::OnManualSubmit); @@ -833,19 +838,19 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames() CHECK_DATABASE(db); QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest3")); + model.setTable(reltest3); model.setEditStrategy(QSqlTableModel::OnManualSubmit); model.setSort(0, Qt::AscendingOrder); // Duplication of "name", used in both reltest3 and reltest4. - model.setRelation(2, QSqlRelation(qTableName("reltest4"), "id", "name")); + model.setRelation(2, QSqlRelation(reltest4, "id", "name")); QVERIFY_SQL(model, select()); if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) { - QCOMPARE(model.record(1).value(qTableName("reltest4").append(QLatin1String("_name_2")).toUpper()).toString(), + QCOMPARE(model.record(1).value((reltest4+QLatin1String("_name_2")).toUpper()).toString(), QString("Trondheim")); } else { - QCOMPARE(model.record(1).value(qTableName("reltest4").append(QLatin1String("_name_2"))).toString(), + QCOMPARE(model.record(1).value((reltest4+QLatin1String("_name_2"))).toString(), QString("Trondheim")); } @@ -864,9 +869,9 @@ void tst_QSqlRelationalTableModel::insertRecordDuplicateFieldNames() // The duplicate field names is aliased because it's comes from the relation's display column. if(db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) - QCOMPARE(rec.fieldName(2), (qTableName("reltest4").append(QLatin1String("_name_2"))).toUpper()); + QCOMPARE(rec.fieldName(2), (reltest4+QLatin1String("_name_2")).toUpper()); else - QCOMPARE(rec.fieldName(2), qTableName("reltest4").append(QLatin1String("_name_2"))); + QCOMPARE(rec.fieldName(2), reltest4+QLatin1String("_name_2")); QVERIFY(model.insertRecord(-1, rec)); QCOMPARE(model.data(model.index(2, 2)).toString(), QString("Oslo")); @@ -881,8 +886,8 @@ void tst_QSqlRelationalTableModel::invalidData() CHECK_DATABASE(db); QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); //try set a non-existent relational key @@ -900,8 +905,8 @@ void tst_QSqlRelationalTableModel::relationModel() CHECK_DATABASE(db); QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QVERIFY(model.relationModel(0) == NULL); @@ -910,7 +915,7 @@ void tst_QSqlRelationalTableModel::relationModel() QVERIFY(model.relationModel(3) == NULL); QVERIFY(model.relationModel(4) == NULL); - model.setRelation(3, QSqlRelation(qTableName("reltest4"), "id", "name")); + model.setRelation(3, QSqlRelation(reltest4, "id", "name")); QVERIFY_SQL(model, select()); QVERIFY(model.relationModel(0) == NULL); @@ -981,7 +986,7 @@ void tst_QSqlRelationalTableModel::casing() QSqlRelationalTableModel model(0, db); model.setTable(qTableName("CASETEST1", db.driver()).toUpper()); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(0, 0)).toInt(), 1); @@ -997,15 +1002,15 @@ void tst_QSqlRelationalTableModel::escapedRelations() recreateTestTables(db); QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); + model.setTable(reltest1); //try with relation table name quoted if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) { - model.setRelation(2, QSqlRelation(db.driver()->escapeIdentifier(qTableName("reltest2").toUpper(),QSqlDriver::TableName), + model.setRelation(2, QSqlRelation(db.driver()->escapeIdentifier(reltest2.toUpper(),QSqlDriver::TableName), "tid", "title")); } else { - model.setRelation(2, QSqlRelation(db.driver()->escapeIdentifier(qTableName("reltest2"),QSqlDriver::TableName), + model.setRelation(2, QSqlRelation(db.driver()->escapeIdentifier(reltest2,QSqlDriver::TableName), "tid", "title")); @@ -1018,11 +1023,11 @@ void tst_QSqlRelationalTableModel::escapedRelations() //try with index column quoted if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) { - model.setRelation(2, QSqlRelation(qTableName("reltest2"), + model.setRelation(2, QSqlRelation(reltest2, db.driver()->escapeIdentifier("tid", QSqlDriver::FieldName).toUpper(), "title")); } else { - model.setRelation(2, QSqlRelation(qTableName("reltest2"), + model.setRelation(2, QSqlRelation(reltest2, db.driver()->escapeIdentifier("tid", QSqlDriver::FieldName), "title")); } @@ -1036,11 +1041,11 @@ void tst_QSqlRelationalTableModel::escapedRelations() if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) { - model.setRelation(2, QSqlRelation(qTableName("reltest2"), + model.setRelation(2, QSqlRelation(reltest2, "tid", db.driver()->escapeIdentifier("title", QSqlDriver::FieldName).toUpper())); } else { - model.setRelation(2, QSqlRelation(qTableName("reltest2"), + model.setRelation(2, QSqlRelation(reltest2, "tid", db.driver()->escapeIdentifier("title", QSqlDriver::FieldName))); } @@ -1054,11 +1059,11 @@ void tst_QSqlRelationalTableModel::escapedRelations() //try with tablename and index and display columns quoted in the relation if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) { - model.setRelation(2, QSqlRelation(qTableName("reltest2"), + model.setRelation(2, QSqlRelation(reltest2, "tid", db.driver()->escapeIdentifier("title", QSqlDriver::FieldName).toUpper())); } else { - model.setRelation(2, QSqlRelation(qTableName("reltest2"), + model.setRelation(2, QSqlRelation(reltest2, "tid", db.driver()->escapeIdentifier("title", QSqlDriver::FieldName))); } @@ -1080,12 +1085,12 @@ void tst_QSqlRelationalTableModel::escapedTableName() QSqlRelationalTableModel model(0, db); if (db.driverName().startsWith("QIBASE") || db.driverName().startsWith("QOCI") || db.driverName().startsWith("QDB2")) { - model.setTable(db.driver()->escapeIdentifier(qTableName("reltest1").toUpper(), QSqlDriver::TableName)); + model.setTable(db.driver()->escapeIdentifier(reltest1.toUpper(), QSqlDriver::TableName)); } else { - model.setTable(db.driver()->escapeIdentifier(qTableName("reltest1"), QSqlDriver::TableName)); + model.setTable(db.driver()->escapeIdentifier(reltest1, QSqlDriver::TableName)); } model.setSort(0, Qt::AscendingOrder); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QVERIFY(model.setData(model.index(0, 1), QString("harry2"))); @@ -1106,7 +1111,7 @@ void tst_QSqlRelationalTableModel::escapedTableName() } { //verify values QSqlRelationalTableModel model(0, db); - model.setTable(qTableName("reltest1")); + model.setTable(reltest1); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -1115,7 +1120,7 @@ void tst_QSqlRelationalTableModel::escapedTableName() QCOMPARE(model.data(model.index(3, 1)).toString(), QString("boris2")); QCOMPARE(model.data(model.index(3, 2)).toInt(), 1); - model.setRelation(2, QSqlRelation(qTableName("reltest2"), "tid", "title")); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); QVERIFY_SQL(model, select()); QCOMPARE(model.data(model.index(0, 2)).toString(), QString("mister")); QCOMPARE(model.data(model.index(3,2)).toString(), QString("herr")); @@ -1132,9 +1137,9 @@ void tst_QSqlRelationalTableModel::whiteSpaceInIdentifiers() if (!testWhiteSpaceNames(db.driverName())) QSKIP("White space test irrelevant for driver", SkipAll); QSqlRelationalTableModel model(0, db); - model.setTable(db.driver()->escapeIdentifier(qTableName("rel test6"), QSqlDriver::TableName)); + model.setTable(db.driver()->escapeIdentifier(qTableName("rel", __FILE__)+" test6", QSqlDriver::TableName)); model.setSort(0, Qt::DescendingOrder); - model.setRelation(1, QSqlRelation(db.driver()->escapeIdentifier(qTableName("rel test7"), QSqlDriver::TableName), + model.setRelation(1, QSqlRelation(db.driver()->escapeIdentifier(qTableName("rel", __FILE__)+" test7", QSqlDriver::TableName), db.driver()->escapeIdentifier("city id", QSqlDriver::FieldName), db.driver()->escapeIdentifier("city name", QSqlDriver::FieldName))); QVERIFY_SQL(model, select()); @@ -1210,13 +1215,13 @@ void tst_QSqlRelationalTableModel::psqlSchemaTest() } QSqlRelationalTableModel model(0, db); QSqlQuery q(db); - QVERIFY_SQL(q, exec("create schema "+qTableName("QTBUG_5373"))); - QVERIFY_SQL(q, exec("create schema "+qTableName("QTBUG_5373_s2"))); - QVERIFY_SQL(q, exec("create table "+qTableName("QTBUG_5373")+"."+qTableName("document")+"(document_id int primary key, relatingid int, userid int)")); - QVERIFY_SQL(q, exec("create table "+qTableName("QTBUG_5373_s2")+"."+qTableName("user")+"(userid int primary key, username char(40))")); - model.setTable(qTableName("QTBUG_5373")+"."+qTableName("document")); - model.setRelation(1, QSqlRelation(qTableName("QTBUG_5373_s2")+"."+qTableName("user"), "userid", "username")); - model.setRelation(2, QSqlRelation(qTableName("QTBUG_5373_s2")+"."+qTableName("user"), "userid", "username")); + QVERIFY_SQL(q, exec("create schema "+qTableName("QTBUG_5373", __FILE__))); + QVERIFY_SQL(q, exec("create schema "+qTableName("QTBUG_5373_s2", __FILE__))); + QVERIFY_SQL(q, exec("create table "+qTableName("QTBUG_5373", __FILE__)+"."+qTableName("document", __FILE__)+"(document_id int primary key, relatingid int, userid int)")); + QVERIFY_SQL(q, exec("create table "+qTableName("QTBUG_5373_s2", __FILE__)+"."+qTableName("user", __FILE__)+"(userid int primary key, username char(40))")); + model.setTable(qTableName("QTBUG_5373", __FILE__)+"."+qTableName("document", __FILE__)); + model.setRelation(1, QSqlRelation(qTableName("QTBUG_5373_s2", __FILE__)+"."+qTableName("user", __FILE__), "userid", "username")); + model.setRelation(2, QSqlRelation(qTableName("QTBUG_5373_s2", __FILE__)+"."+qTableName("user", __FILE__), "userid", "username")); QVERIFY_SQL(model, select()); } diff --git a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp index b295838..8a084bb 100644 --- a/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp +++ b/tests/auto/qsqltablemodel/tst_qsqltablemodel.cpp @@ -44,6 +44,10 @@ #include "../qsqldatabase/tst_databases.h" #include <QtSql> +const QString test(qTableName("test", __FILE__)), + test2(qTableName("test2", __FILE__)), + test3(qTableName("test3", __FILE__)); + //TESTED_CLASS= //TESTED_FILES= @@ -147,20 +151,20 @@ void tst_QSqlTableModel::dropTestTables() QVERIFY_SQL( q, exec("set client_min_messages='warning'")); QStringList tableNames; - tableNames << qTableName("test") - << qTableName("test2") - << qTableName("test3") - << qTableName("test4") - << qTableName("emptytable") - << qTableName("bigtable") - << qTableName("foo"); + tableNames << test + << test2 + << test3 + << qTableName("test4", __FILE__) + << qTableName("emptytable", __FILE__) + << qTableName("bigtable", __FILE__) + << qTableName("foo", __FILE__); if (testWhiteSpaceNames(db.driverName())) tableNames << qTableName("qtestw hitespace", db.driver()); tst_Databases::safeDropTables(db, tableNames); if (db.driverName().startsWith("QPSQL")) { - q.exec("DROP SCHEMA " + qTableName("testschema") + " CASCADE"); + q.exec("DROP SCHEMA " + qTableName("testschema", __FILE__) + " CASCADE"); } } } @@ -171,15 +175,15 @@ void tst_QSqlTableModel::createTestTables() QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlQuery q(db); - QVERIFY_SQL( q, exec("create table " + qTableName("test") + "(id int, name varchar(20), title int)")); + QVERIFY_SQL( q, exec("create table " + test + "(id int, name varchar(20), title int)")); - QVERIFY_SQL( q, exec("create table " + qTableName("test2") + "(id int, title varchar(20))")); + QVERIFY_SQL( q, exec("create table " + test2 + "(id int, title varchar(20))")); - QVERIFY_SQL( q, exec("create table " + qTableName("test3") + "(id int, random varchar(20), randomtwo varchar(20))")); + QVERIFY_SQL( q, exec("create table " + test3 + "(id int, random varchar(20), randomtwo varchar(20))")); - QVERIFY_SQL( q, exec("create table " + qTableName("test4") + "(column1 varchar(50), column2 varchar(50), column3 varchar(50))")); + QVERIFY_SQL( q, exec("create table " + qTableName("test4", __FILE__) + "(column1 varchar(50), column2 varchar(50), column3 varchar(50))")); - QVERIFY_SQL( q, exec("create table " + qTableName("emptytable") + "(id int)")); + QVERIFY_SQL( q, exec("create table " + qTableName("emptytable", __FILE__) + "(id int)")); if (testWhiteSpaceNames(db.driverName())) { QString qry = "create table " + qTableName("qtestw hitespace", db.driver()) + " ("+ db.driver()->escapeIdentifier("a field", QSqlDriver::FieldName) + " int)"; @@ -194,18 +198,18 @@ void tst_QSqlTableModel::repopulateTestTables() QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlQuery q(db); - q.exec("delete from " + qTableName("test")); - QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(1, 'harry', 1)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(2, 'trond', 2)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(3, 'vohi', 3)")); + q.exec("delete from " + test); + QVERIFY_SQL( q, exec("insert into " + test + " values(1, 'harry', 1)")); + QVERIFY_SQL( q, exec("insert into " + test + " values(2, 'trond', 2)")); + QVERIFY_SQL( q, exec("insert into " + test + " values(3, 'vohi', 3)")); - q.exec("delete from " + qTableName("test2")); - QVERIFY_SQL( q, exec("insert into " + qTableName("test2") + " values(1, 'herr')")); - QVERIFY_SQL( q, exec("insert into " + qTableName("test2") + " values(2, 'mister')")); + q.exec("delete from " + test2); + QVERIFY_SQL( q, exec("insert into " + test2 + " values(1, 'herr')")); + QVERIFY_SQL( q, exec("insert into " + test2 + " values(2, 'mister')")); - q.exec("delete from " + qTableName("test3")); - QVERIFY_SQL( q, exec("insert into " + qTableName("test3") + " values(1, 'foo', 'bar')")); - QVERIFY_SQL( q, exec("insert into " + qTableName("test3") + " values(2, 'baz', 'joe')")); + q.exec("delete from " + test3); + QVERIFY_SQL( q, exec("insert into " + test3 + " values(1, 'foo', 'bar')")); + QVERIFY_SQL( q, exec("insert into " + test3 + " values(2, 'baz', 'joe')")); } } @@ -253,7 +257,7 @@ void tst_QSqlTableModel::select() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -294,7 +298,7 @@ void tst_QSqlTableModel::setRecord() QSqlTableModel model(0, db); model.setEditStrategy((QSqlTableModel::EditStrategy)submitpolicy); - model.setTable(qTableName("test3")); + model.setTable(test3); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -336,7 +340,7 @@ void tst_QSqlTableModel::insertRow() QSqlTableModel model(0, db); model.setEditStrategy(QSqlTableModel::OnRowChange); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -361,7 +365,7 @@ void tst_QSqlTableModel::insertRecord() QSqlTableModel model(0, db); model.setEditStrategy(QSqlTableModel::OnManualSubmit); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -394,7 +398,7 @@ void tst_QSqlTableModel::insertMultiRecords() QSqlTableModel model(0, db); model.setEditStrategy(QSqlTableModel::OnManualSubmit); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -421,7 +425,7 @@ void tst_QSqlTableModel::insertMultiRecords() QVERIFY(model.submitAll()); model.clear(); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); QVERIFY_SQL(model, select()); @@ -442,7 +446,7 @@ void tst_QSqlTableModel::submitAll() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); model.setEditStrategy(QSqlTableModel::OnManualSubmit); QVERIFY_SQL(model, select()); @@ -477,7 +481,7 @@ void tst_QSqlTableModel::removeRow() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); model.setEditStrategy(QSqlTableModel::OnManualSubmit); QVERIFY_SQL(model, select()); @@ -502,7 +506,7 @@ void tst_QSqlTableModel::removeRow() recreateTestTables(); - model.setTable(qTableName("test")); + model.setTable(test); model.setEditStrategy(QSqlTableModel::OnRowChange); QVERIFY_SQL(model, select()); QCOMPARE(model.rowCount(), 3); @@ -523,7 +527,7 @@ void tst_QSqlTableModel::removeRows() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); model.setEditStrategy(QSqlTableModel::OnFieldChange); QVERIFY_SQL(model, select()); @@ -539,7 +543,7 @@ void tst_QSqlTableModel::removeRows() model.clear(); recreateTestTables(); - model.setTable(qTableName("test")); + model.setTable(test); model.setEditStrategy(QSqlTableModel::OnManualSubmit); QVERIFY_SQL(model, select()); QCOMPARE(model.rowCount(), 3); @@ -574,7 +578,7 @@ void tst_QSqlTableModel::removeInsertedRow() for (int i = 0; i <= 1; ++i) { QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setSort(0, Qt::AscendingOrder); model.setEditStrategy(i == 0 @@ -607,7 +611,7 @@ void tst_QSqlTableModel::emptyTable() QCOMPARE(model.rowCount(), 0); QCOMPARE(model.columnCount(), 0); - model.setTable(qTableName("emptytable")); + model.setTable(qTableName("emptytable", __FILE__)); QCOMPARE(model.rowCount(), 0); QCOMPARE(model.columnCount(), 1); @@ -623,9 +627,9 @@ void tst_QSqlTableModel::tablesAndSchemas() CHECK_DATABASE(db); QSqlQuery q(db); - q.exec("DROP SCHEMA " + qTableName("testschema") + " CASCADE"); - QVERIFY_SQL( q, exec("create schema " + qTableName("testschema"))); - QString tableName = qTableName("testschema") + '.' + qTableName("testtable"); + q.exec("DROP SCHEMA " + qTableName("testschema", __FILE__) + " CASCADE"); + QVERIFY_SQL( q, exec("create schema " + qTableName("testschema", __FILE__))); + QString tableName = qTableName("testschema", __FILE__) + '.' + qTableName("testtable", __FILE__); QVERIFY_SQL( q, exec("create table " + tableName + "(id int)")); QVERIFY_SQL( q, exec("insert into " + tableName + " values(1)")); QVERIFY_SQL( q, exec("insert into " + tableName + " values(2)")); @@ -664,10 +668,10 @@ void tst_QSqlTableModel::primaryKeyOrder() if(tst_Databases::isPostgreSQL(db)) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); - QVERIFY_SQL( q, exec("create table "+qTableName("foo")+"(a varchar(20), id int not null primary key, b varchar(20))")); + QVERIFY_SQL( q, exec("create table "+qTableName("foo", __FILE__)+"(a varchar(20), id int not null primary key, b varchar(20))")); QSqlTableModel model(0, db); - model.setTable(qTableName("foo")); + model.setTable(qTableName("foo", __FILE__)); QSqlIndex pk = model.primaryKey(); QCOMPARE(pk.count(), 1); @@ -693,7 +697,7 @@ void tst_QSqlTableModel::setInvalidFilter() // set an invalid filter, make sure it fails QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setFilter("blahfahsel"); QCOMPARE(model.filter(), QString("blahfahsel")); @@ -711,7 +715,7 @@ void tst_QSqlTableModel::setFilter() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setFilter("id = 1"); QCOMPARE(model.filter(), QString("id = 1")); QVERIFY_SQL(model, select()); @@ -762,12 +766,13 @@ void tst_QSqlTableModel::sqlite_bigTable() QFETCH(QString, dbName); QSqlDatabase db = QSqlDatabase::database(dbName); CHECK_DATABASE(db); + const QString bigtable(qTableName("bigtable", __FILE__)); bool hasTransactions = db.driver()->hasFeature(QSqlDriver::Transactions); if (hasTransactions) QVERIFY(db.transaction()); QSqlQuery q(db); - QVERIFY_SQL( q, exec("create table "+qTableName("bigtable")+"(id int primary key, name varchar)")); - QVERIFY_SQL( q, prepare("insert into "+qTableName("bigtable")+"(id, name) values (?, ?)")); + QVERIFY_SQL( q, exec("create table "+bigtable+"(id int primary key, name varchar)")); + QVERIFY_SQL( q, prepare("insert into "+bigtable+"(id, name) values (?, ?)")); QTime startTime; startTime.start(); for (int i = 0; i < 10000; ++i) { @@ -781,7 +786,7 @@ void tst_QSqlTableModel::sqlite_bigTable() if (hasTransactions) QVERIFY(db.commit()); QSqlTableModel model(0, db); - model.setTable(qTableName("bigtable")); + model.setTable(bigtable); QVERIFY_SQL(model, select()); QSqlRecord rec = model.record(); @@ -801,7 +806,7 @@ void tst_QSqlTableModel::insertRecordBeforeSelect() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); QCOMPARE(model.lastError().type(), QSqlError::NoError); QSqlRecord buffer = model.record(); @@ -820,7 +825,7 @@ void tst_QSqlTableModel::insertRecordBeforeSelect() QCOMPARE(model.rowCount(), 0); QSqlTableModel model2(0, db); - model2.setTable(qTableName("test")); + model2.setTable(test); QVERIFY_SQL(model2, select()); QCOMPARE(model2.rowCount(), rowCount); } @@ -838,7 +843,7 @@ void tst_QSqlTableModel::submitAllOnInvalidTable() // setTable returns a void, so the error can only be caught by // manually checking lastError(). ### Qt5: This should be changed! - model.setTable(qTableName("invalidTable")); + model.setTable(qTableName("invalidTable", __FILE__)); QCOMPARE(model.lastError().type(), QSqlError::StatementError); // This will give us an empty record which is expected behavior @@ -866,7 +871,7 @@ void tst_QSqlTableModel::insertRecordsInLoop() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setEditStrategy(QSqlTableModel::OnManualSubmit); model.select(); @@ -952,7 +957,7 @@ void tst_QSqlTableModel::tableModifyWithBlank() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test4")); + model.setTable(qTableName("test4", __FILE__)); model.select(); //generate a time stamp for the test. Add one second to the current time to make sure @@ -1008,7 +1013,7 @@ void tst_QSqlTableModel::removeColumnAndRow() CHECK_DATABASE(db); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setEditStrategy(QSqlTableModel::OnManualSubmit); QVERIFY_SQL(model, select()); QCOMPARE(model.rowCount(), 3); @@ -1023,7 +1028,7 @@ void tst_QSqlTableModel::removeColumnAndRow() // check with another table because the model has been modified // but not the sql table QSqlTableModel model2(0, db); - model2.setTable(qTableName("test")); + model2.setTable(test); QVERIFY_SQL(model2, select()); QCOMPARE(model2.rowCount(), 2); QCOMPARE(model2.columnCount(), 3); @@ -1036,11 +1041,11 @@ void tst_QSqlTableModel::insertBeforeDelete() CHECK_DATABASE(db); QSqlQuery q(db); - QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(9, 'andrew', 9)")); - QVERIFY_SQL( q, exec("insert into " + qTableName("test") + " values(10, 'justin', 10)")); + QVERIFY_SQL( q, exec("insert into " + test + " values(9, 'andrew', 9)")); + QVERIFY_SQL( q, exec("insert into " + test + " values(10, 'justin', 10)")); QSqlTableModel model(0, db); - model.setTable(qTableName("test")); + model.setTable(test); model.setEditStrategy(QSqlTableModel::OnManualSubmit); QVERIFY_SQL(model, select()); diff --git a/tests/auto/qsqlthread/tst_qsqlthread.cpp b/tests/auto/qsqlthread/tst_qsqlthread.cpp index 632586a28..791f804 100644 --- a/tests/auto/qsqlthread/tst_qsqlthread.cpp +++ b/tests/auto/qsqlthread/tst_qsqlthread.cpp @@ -53,6 +53,7 @@ #include <pthread.h> #endif +const QString qtest(qTableName("qtest", __FILE__)); // set this define if Oracle is built with threading support //#define QOCI_THREADED @@ -115,7 +116,7 @@ public: QVERIFY_SQL(db, open()); int sum = 0; - QSqlQuery q("select id from " + qTableName("test"), db); + QSqlQuery q("select id from " + qtest, db); QVERIFY_SQL(q, isActive()); while (q.next()) sum += q.value(0).toInt(); @@ -150,7 +151,7 @@ public: QSqlDatabase db = QSqlDatabase::cloneDatabase(sourceDb, dbName); QVERIFY_SQL(db, open()); QSqlQuery q(db); - QVERIFY_SQL(q, prepare("insert into " + qTableName("test") + " values (?, ?, ?)")); + QVERIFY_SQL(q, prepare("insert into " + qtest + " values (?, ?, ?)")); int id = 10; for (int i = 0; i < ProdConIterations; ++i) { q.bindValue(0, ++id); @@ -187,10 +188,10 @@ public: QSqlDatabase db = QSqlDatabase::cloneDatabase(sourceDb, dbName); QVERIFY_SQL(db, open()); QSqlQuery q1(db), q2(db); - QVERIFY_SQL(q2, prepare("delete from " + qTableName("test") + " where id = :id")); + QVERIFY_SQL(q2, prepare("delete from " + qtest + " where id = :id")); for (int i = 0; i < ProdConIterations; ++i) { - QVERIFY_SQL(q1, exec("select max(id) from " + qTableName("test"))); + QVERIFY_SQL(q1, exec("select max(id) from " + qtest)); q1.first(); q2.bindValue("id", q1.value(0)); q1.clear(); @@ -231,7 +232,7 @@ public: // Executes a Query for reading, iterates over the first 4 results QSqlQuery q(sourceDb); for (int j = 0; j < ProdConIterations; ++j) { - QVERIFY_SQL(q, exec("select id,name from " + qTableName("test") + " order by id")); + QVERIFY_SQL(q, exec("select id,name from " + qtest + " order by id")); for (int i = 1; i < 4; ++i) { QVERIFY_SQL(q, next()); QCOMPARE(q.value(0).toInt(), i); @@ -242,7 +243,7 @@ public: // Executes a query for writing (appends a new row) QSqlQuery q(sourceDb); for (int j = 0; j < ProdConIterations; ++j) { - QVERIFY_SQL(q, exec(QString("insert into " + qTableName("test") + QVERIFY_SQL(q, exec(QString("insert into " + qtest + " (id, name) values(%1, '%2')") .arg(counter.fetchAndAddRelaxed(1)).arg("Robert"))); } @@ -250,7 +251,7 @@ public: case PreparedReading: { // Prepares a query for reading and iterates over the results QSqlQuery q(sourceDb); - QVERIFY_SQL(q, prepare("select id, name from " + qTableName("test") + " where id = ?")); + QVERIFY_SQL(q, prepare("select id, name from " + qtest + " where id = ?")); for (int j = 0; j < ProdConIterations; ++j) { q.addBindValue(j % 3 + 1); QVERIFY_SQL(q, exec()); @@ -260,7 +261,7 @@ public: break; } case PreparedWriting: { QSqlQuery q(sourceDb); - QVERIFY_SQL(q, prepare("insert into " + qTableName("test") + " (id, name) " + QVERIFY_SQL(q, prepare("insert into " + qtest + " (id, name) " "values(?, ?)")); for (int i = 0; i < ProdConIterations; ++i) { q.addBindValue(counter.fetchAndAddRelaxed(1)); @@ -302,7 +303,7 @@ void tst_QSqlThread::dropTestTables() QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlQuery q(db); - tst_Databases::safeDropTables(db, QStringList() << qTableName("test") << qTableName("test2") << qTableName("emptytable")); + tst_Databases::safeDropTables(db, QStringList() << qtest << qTableName("qtest2", __FILE__) << qTableName("emptytable", __FILE__)); } } @@ -312,13 +313,13 @@ void tst_QSqlThread::createTestTables() QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlQuery q(db); - QVERIFY_SQL(q, exec("create table " + qTableName("test") + QVERIFY_SQL(q, exec("create table " + qtest + "(id int NOT NULL primary key, name varchar(20), title int)")); - QVERIFY_SQL(q, exec("create table " + qTableName("test2") + QVERIFY_SQL(q, exec("create table " + qTableName("qtest2", __FILE__) + "(id int NOT NULL primary key, title varchar(20))")); - QVERIFY_SQL(q, exec("create table " + qTableName("emptytable") + QVERIFY_SQL(q, exec("create table " + qTableName("emptytable", __FILE__) + "(id int NOT NULL primary key)")); } } @@ -329,14 +330,14 @@ void tst_QSqlThread::repopulateTestTables() QSqlDatabase db = QSqlDatabase::database(dbs.dbNames.at(i)); QSqlQuery q(db); - QVERIFY_SQL(q, exec("delete from " + qTableName("test"))); - QVERIFY_SQL(q, exec("insert into " + qTableName("test") + " values(1, 'harry', 1)")); - QVERIFY_SQL(q, exec("insert into " + qTableName("test") + " values(2, 'trond', 2)")); - QVERIFY_SQL(q, exec("insert into " + qTableName("test") + " values(3, 'vohi', 3)")); + QVERIFY_SQL(q, exec("delete from " + qtest)); + QVERIFY_SQL(q, exec("insert into " + qtest + " values(1, 'harry', 1)")); + QVERIFY_SQL(q, exec("insert into " + qtest + " values(2, 'trond', 2)")); + QVERIFY_SQL(q, exec("insert into " + qtest + " values(3, 'vohi', 3)")); - QVERIFY_SQL(q, exec("delete from " + qTableName("test2"))); - QVERIFY_SQL(q, exec("insert into " + qTableName("test2") + " values(1, 'herr')")); - QVERIFY_SQL(q, exec("insert into " + qTableName("test2") + " values(2, 'mister')")); + QVERIFY_SQL(q, exec("delete from " + qTableName("qtest2", __FILE__))); + QVERIFY_SQL(q, exec("insert into " + qTableName("qtest2", __FILE__) + " values(1, 'herr')")); + QVERIFY_SQL(q, exec("insert into " + qTableName("qtest2", __FILE__) + " values(2, 'mister')")); } } diff --git a/tests/auto/qsslkey/rsa-with-passphrase.pem b/tests/auto/qsslkey/rsa-with-passphrase.pem new file mode 100644 index 0000000..cb29bec --- /dev/null +++ b/tests/auto/qsslkey/rsa-with-passphrase.pem @@ -0,0 +1,18 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-CBC,36BD1242254C5E1E + +sqt8qlQfkjJiz0djd0WYjhN/IGxA/nU/wVKuf5RWDAghDBrABzJ3dU4Jh1WIsS4+ +f22TBr6fwgjpPxGkt361Z9oxon/QeyBZLFtyUxnFSqZcVMMR3vndtMyYJbVKjRm1 +lvF3BjFWNh6+SZe20cut2GiUJDqhw7RbjaAN6LaCpFqwusY6vbjW6vzB8ezDvLou +5jQAkwArGoI0KqUMwBOYukiWdBA0iERavspKGRnB3mGtgv5ziTEFzx58mn1Lv3Qs +LYQqTYgzpFyAMP9SZaRv4m/y5O9foAXnlh0GhmDWBQ2D5flwZqrIAzoJ5BcZKU6/ +HJCh4snw3kheeE8NhrlzypEONedvu4ifUbqN5idMU7S4t40NAmQ/dF0Z4wDen/M/ +iFbt5tTWh6sXK82XzJtAfprH07odtJHK7CMeurCi5BupmnLtPbUrl6hpKItBzu+g +7MB5AyNk548V9Y8+kKBtEG5EgYZrMYX4yqQ+Z8F1hy0UUMXu9cAnO06OTavxLtWJ +ikmwYJNy421Hj+oZVSagCUILQyUfgx6fXWwDRqy/stlX+hpPPjVmd/A2WBm5x/Sf +5CGfUtddZRuAZpChBXV6a/R+nMzDXhkKl4XTkN8hg3yXLY6xy3CR3RIYDlKkn85y +VziP32V6Bc8ucGifsZLNnvj8CFXTZP+8CWun9yLSkcq+wm4cQOLswztEMA8bbPJQ +g7Gp59BC4ofN5bMZ1R1z+l96x+YMY9btkyjE1uEyRT88dHwxnkhC5AKBx2P6sg0C +doe5Dh8Ny5Ic24ibwyvZbAS46tSVdha7ACGnGXV4Z3iqBfN0b0UNmw== +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/qsslkey/rsa-without-passphrase.pem b/tests/auto/qsslkey/rsa-without-passphrase.pem new file mode 100644 index 0000000..f7c834b --- /dev/null +++ b/tests/auto/qsslkey/rsa-without-passphrase.pem @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXQIBAAKBgQC1mZlLC6g8/vaw8XEOQ59gwQ5WxIvcKCSx7B5SHaeN8zzbENpl +32BtyfrCccHF7j6qwfMZ2RwM5RTlFw/eBF4SSXAgp/P5CgcugSs1dOJUfPveos/5 +h3fmnUcKeQIU4m5EGcQicmR8//WUUfdtHDp/fJ0dRXcY2tTOx89vNPEtgwIDAQAB +AoGBAKqE2f4vqf/sYPPxInmEYclWPgKXd8R4JUy0LBxrIAQYXBJPluOFhmRQ/hdK +/eq/NTTd/UlOJhqtmJsstoeAjlsELl2AejX2n1B9aSffQ0WzdB5gVMNotPGRKRIG +eOq2pp2JOFkGps11LUAqDEMNUb3EV6HiBucoGEOUpdITLrRxAkEA4Ul3o44wMvIb +muwp7/erSvDMWRZ1GjksEmBMAHL6y8avZd9UgrjHeCy8uHXrT0id4Cig8FA+nQA5 +UwTr9y5e9wJBAM5bc8xuAuCg4Si3exssFfxQIxFTmPzhkVubglO9IcLqfXLl3k5S +CxgRb/4pBMKVRCMRXAkaZpjJqTIofjp4ptUCQQC4hySnot932zchPi9bjtGPII1A +q1RfllSy+I1IEOW745HnL3ZZXGCF3p71uCB1YFVwNdcc/51Jm9VYWr+sRx8hAkBL +KoTDsk7aA8AAVNVC0Iwxm/8qEIlpk8Ce3cZbOklR9pg7gf+4B6qC2dcxfT9+oWBw +ZaJgrn0wqkQ3QQi5w7kBAkBAR2tKc2OqnljMPnXYEreRyHHjhqCsJYFAE7u16cY/ +NQGJq9jBAD5WANclrYRxKtD6yohi+Y7Vi7+SXve3pGdF +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/qsslkey/tst_qsslkey.cpp b/tests/auto/qsslkey/tst_qsslkey.cpp index d156344..3c8ae11 100644 --- a/tests/auto/qsslkey/tst_qsslkey.cpp +++ b/tests/auto/qsslkey/tst_qsslkey.cpp @@ -99,6 +99,7 @@ private slots: void toEncryptedPemOrDer_data(); void toEncryptedPemOrDer(); + void passphraseChecks(); #endif }; @@ -371,6 +372,77 @@ void tst_QSslKey::toEncryptedPemOrDer() // ### add a test to verify that public keys are _decrypted_ correctly (by the ctor) } +void tst_QSslKey::passphraseChecks() +{ + { + QString fileName(SRCDIR "/rsa-with-passphrase.pem"); + QFile keyFile(fileName); + QVERIFY(keyFile.exists()); + { + if (!keyFile.isOpen()) + keyFile.open(QIODevice::ReadOnly); + else + keyFile.reset(); + QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey); + QVERIFY(key.isNull()); // null passphrase => should not be able to decode key + } + { + if (!keyFile.isOpen()) + keyFile.open(QIODevice::ReadOnly); + else + keyFile.reset(); + QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, ""); + QVERIFY(key.isNull()); // empty passphrase => should not be able to decode key + } + { + if (!keyFile.isOpen()) + keyFile.open(QIODevice::ReadOnly); + else + keyFile.reset(); + QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, "WRONG!"); + QVERIFY(key.isNull()); // wrong passphrase => should not be able to decode key + } + { + if (!keyFile.isOpen()) + keyFile.open(QIODevice::ReadOnly); + else + keyFile.reset(); + QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, "123"); + QVERIFY(!key.isNull()); // correct passphrase + } + } + + { + // be sure and check a key without passphrase too + QString fileName(SRCDIR "/rsa-without-passphrase.pem"); + QFile keyFile(fileName); + { + if (!keyFile.isOpen()) + keyFile.open(QIODevice::ReadOnly); + else + keyFile.reset(); + QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey); + QVERIFY(!key.isNull()); // null passphrase => should be able to decode key + } + { + if (!keyFile.isOpen()) + keyFile.open(QIODevice::ReadOnly); + else + keyFile.reset(); + QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, ""); + QVERIFY(!key.isNull()); // empty passphrase => should be able to decode key + } + { + if (!keyFile.isOpen()) + keyFile.open(QIODevice::ReadOnly); + else + keyFile.reset(); + QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, "xxx"); + QVERIFY(!key.isNull()); // passphrase given but key is not encrypted anyway => should work + } + } +} + #endif QTEST_MAIN(tst_QSslKey) diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index ad2b50d..4397ab1 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -666,6 +666,21 @@ void tst_QSslSocket::isEncrypted() void tst_QSslSocket::localCertificate() { + if (!QSslSocket::supportsSsl()) + return; + + // This test does not make 100% sense yet. We just set some local CA/cert/key and use it + // to authenticate ourselves against the server. The server does not actually check this + // values. This test should just run the codepath inside qsslsocket_openssl.cpp + + QSslSocketPtr socket = newSocket(); + QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem"); + socket->setCaCertificates(localCert); + socket->setLocalCertificate(QLatin1String(SRCDIR "certs/fluke.cert")); + socket->setPrivateKey(QLatin1String(SRCDIR "certs/fluke.key")); + + socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + QVERIFY(socket->waitForEncrypted(5000)); } void tst_QSslSocket::mode() diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 35fba52..54e32218 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -201,6 +201,7 @@ private slots: void taskQTBUG_5237_wheelEventOnHeader(); void taskQTBUG_8585_crashForNoGoodReason(); void taskQTBUG_7774_RtoLVisualRegionForSelection(); + void taskQTBUG_8777_scrollToSpans(); void mouseWheel_data(); void mouseWheel(); @@ -3994,7 +3995,6 @@ void tst_QTableView::taskQTBUG_8585_crashForNoGoodReason() } } - class TableView7774 : public QTableView { public: @@ -4020,5 +4020,19 @@ void tst_QTableView::taskQTBUG_7774_RtoLVisualRegionForSelection() QCOMPARE(region.rects().at(0), view.visualRect(range.topLeft()) | view.visualRect(range.bottomRight())); } +void tst_QTableView::taskQTBUG_8777_scrollToSpans() +{ + QTableWidget table(75,5); + for (int i=0; i<50; i++) + table.setSpan(2+i, 0, 1, 5); + table.setCurrentCell(0,2); + table.show(); + + for (int i = 0; i < 45; ++i) + QTest::keyClick(&table, Qt::Key_Down); + + QVERIFY(table.verticalScrollBar()->value() > 10); +} + QTEST_MAIN(tst_QTableView) #include "tst_qtableview.moc" diff --git a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp index 29cb341..4f7822d 100644 --- a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp +++ b/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp @@ -90,7 +90,7 @@ int distance(TestIterator &a, TestIterator &b) using namespace QtConcurrent; -class tst_iteratekernel: public QObject +class tst_QtConcurrentIterateKernel: public QObject { Q_OBJECT private slots: @@ -149,13 +149,13 @@ public: }; -void tst_iteratekernel::instantiate() +void tst_QtConcurrentIterateKernel::instantiate() { startThreadEngine(new PrintFor(0, 40)).startBlocking(); QCOMPARE((int)iterations, 40); } -void tst_iteratekernel::cancel() +void tst_QtConcurrentIterateKernel::cancel() { { QFuture<void> f = startThreadEngine(new SleepPrintFor(0, 40)).startAsynchronously(); @@ -182,7 +182,7 @@ public: } }; -void tst_iteratekernel::stresstest() +void tst_QtConcurrentIterateKernel::stresstest() { const int iterations = 1000; const int times = 50; @@ -194,7 +194,7 @@ void tst_iteratekernel::stresstest() } } -void tst_iteratekernel::noIterations() +void tst_QtConcurrentIterateKernel::noIterations() { const int times = 20000; for (int i = 0; i < times; ++i) @@ -242,7 +242,7 @@ public: bool throttling; }; -void tst_iteratekernel::throttling() +void tst_QtConcurrentIterateKernel::throttling() { const int totalIterations = 400; iterations = 0; @@ -271,7 +271,7 @@ public: } }; -void tst_iteratekernel::blockSize() +void tst_QtConcurrentIterateKernel::blockSize() { #ifdef QT_NO_STL QSKIP("Missing stl iterators prevent correct block size calculation", SkipAll); @@ -296,7 +296,7 @@ public: }; -void tst_iteratekernel::multipleResults() +void tst_QtConcurrentIterateKernel::multipleResults() { #ifdef QT_NO_STL QSKIP("Missing stl iterators prevent correct summation", SkipAll); @@ -320,7 +320,7 @@ public: } }; -void tst_iteratekernel::instantiateWhile() +void tst_QtConcurrentIterateKernel::instantiateWhile() { PrintWhile w; w.startBlocking(); @@ -339,7 +339,7 @@ public: } }; -void tst_iteratekernel::stresstestWhile() +void tst_QtConcurrentIterateKernel::stresstestWhile() { int iterations = 100000; StressWhile w(iterations); @@ -348,7 +348,7 @@ void tst_iteratekernel::stresstestWhile() } #endif -QTEST_MAIN(tst_iteratekernel) +QTEST_MAIN(tst_QtConcurrentIterateKernel) #include "tst_qtconcurrentiteratekernel.moc" diff --git a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp index d3417b1..894bac4 100644 --- a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp +++ b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp @@ -56,7 +56,7 @@ Q_DECLARE_METATYPE(QList<int>); Q_DECLARE_METATYPE(QList<double>); Q_DECLARE_METATYPE(QList<QString>); -class tst_map: public QObject +class tst_QtConcurrentMap: public QObject { Q_OBJECT private slots: @@ -114,7 +114,7 @@ public: Q_DECLARE_METATYPE(QList<Number>); -void tst_map::map() +void tst_QtConcurrentMap::map() { // functors take arguments by reference, modifying the sequence in place { @@ -246,7 +246,7 @@ void tst_map::map() #endif } -void tst_map::blocking_map() +void tst_QtConcurrentMap::blocking_map() { // functors take arguments by reference, modifying the sequence in place { @@ -428,7 +428,7 @@ public: } }; -void tst_map::mapped() +void tst_QtConcurrentMap::mapped() { QList<int> list; list << 1 << 2 << 3; @@ -790,7 +790,7 @@ void tst_map::mapped() } } -void tst_map::blocking_mapped() +void tst_QtConcurrentMap::blocking_mapped() { QList<int> list; list << 1 << 2 << 3; @@ -1244,7 +1244,7 @@ public: } }; -void tst_map::mappedReduced() +void tst_QtConcurrentMap::mappedReduced() { QList<int> list; list << 1 << 2 << 3; @@ -1625,7 +1625,7 @@ void tst_map::mappedReduced() // ### the same as above, with an initial result value } -void tst_map::blocking_mappedReduced() +void tst_QtConcurrentMap::blocking_mappedReduced() { QList<int> list; list << 1 << 2 << 3; @@ -2010,7 +2010,7 @@ int sleeper(int val) return val; } -void tst_map::assignResult() +void tst_QtConcurrentMap::assignResult() { const QList<int> startList = QList<int>() << 0 << 1 << 2; QList<int> list = QtConcurrent::blockingMapped(startList, sleeper); @@ -2077,7 +2077,7 @@ public: Q_DECLARE_METATYPE(QVector<MemFnTester>); Q_DECLARE_METATYPE(QList<MemFnTester>); -void tst_map::functionOverloads() +void tst_QtConcurrentMap::functionOverloads() { QList<int> intList; const QList<int> constIntList; @@ -2159,7 +2159,7 @@ void fastReduce(int &result, const InstanceCounter&) ++result; } -void tst_map::throttling() +void tst_QtConcurrentMap::throttling() { const int itemcount = 100; const int allowedTemporaries = QThread::idealThreadCount() * 40; @@ -2208,7 +2208,7 @@ void throwMapper(int &e) throw QtConcurrent::Exception(); } -void tst_map::exceptions() +void tst_QtConcurrentMap::exceptions() { bool caught = false; try { @@ -2228,7 +2228,7 @@ int mapper(const int &i) return i; } -void tst_map::incrementalResults() +void tst_QtConcurrentMap::incrementalResults() { const int count = 200; QList<int> ints; @@ -2256,7 +2256,7 @@ void tst_map::incrementalResults() Test that mapped does not cause deep copies when holding references to Qt containers. */ -void tst_map::noDetatch() +void tst_QtConcurrentMap::noDetatch() { { QList<int> l = QList<int>() << 1; @@ -2299,7 +2299,7 @@ void tst_map::noDetatch() } -void tst_map::stlContainers() +void tst_QtConcurrentMap::stlContainers() { #ifdef QT_NO_STL QSKIP("Qt compiled without STL support", SkipAll); @@ -2331,7 +2331,7 @@ InstanceCounter ic_fn(const InstanceCounter & ic) // Verify that held results are deleted when a future is // assigned over with operator == -void tst_map::qFutureAssignmentLeak() +void tst_QtConcurrentMap::qFutureAssignmentLeak() { currentInstanceCount = 0; peakInstanceCount = 0; @@ -2370,7 +2370,7 @@ void add(int &result, const int &sum) result += sum; } -void tst_map::stressTest() +void tst_QtConcurrentMap::stressTest() { const int listSize = 1000; const int sum = (listSize - 1) * (listSize / 2); @@ -2399,26 +2399,26 @@ void tst_map::stressTest() } } -QTEST_MAIN(tst_map) +QTEST_MAIN(tst_QtConcurrentMap) #else -void tst_map::map() {} -void tst_map::blocking_map() {} -void tst_map::mapped() {} -void tst_map::blocking_mapped() {} -void tst_map::mappedReduced() {} -void tst_map::blocking_mappedReduced() {} -void tst_map::assignResult() {} -void tst_map::functionOverloads() {} +void tst_QtConcurrentMap::map() {} +void tst_QtConcurrentMap::blocking_map() {} +void tst_QtConcurrentMap::mapped() {} +void tst_QtConcurrentMap::blocking_mapped() {} +void tst_QtConcurrentMap::mappedReduced() {} +void tst_QtConcurrentMap::blocking_mappedReduced() {} +void tst_QtConcurrentMap::assignResult() {} +void tst_QtConcurrentMap::functionOverloads() {} #ifndef QT_NO_EXCEPTIONS -void tst_map::exceptions() {} +void tst_QtConcurrentMap::exceptions() {} #endif -void tst_map::incrementalResults() {} -void tst_map::stressTest() {} -void tst_map::throttling() {} -void tst_map::stlContainers() {} -void tst_map::noDetatch() {} +void tst_QtConcurrentMap::incrementalResults() {} +void tst_QtConcurrentMap::stressTest() {} +void tst_QtConcurrentMap::throttling() {} +void tst_QtConcurrentMap::stlContainers() {} +void tst_QtConcurrentMap::noDetatch() {} QTEST_NOOP_MAIN diff --git a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp index b9ab6d3..8fdc50c 100644 --- a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -49,7 +49,7 @@ using namespace QtConcurrent; -class TestRunFunction: public QObject +class tst_QtConcurrentRun: public QObject { Q_OBJECT private slots: @@ -73,7 +73,7 @@ private slots: #endif -QTEST_MAIN(TestRunFunction) +QTEST_MAIN(tst_QtConcurrentRun) void light() { @@ -91,7 +91,7 @@ void heavy() } -void TestRunFunction::runLightFunction() +void tst_QtConcurrentRun::runLightFunction() { qDebug("starting function"); QFuture<void> future = run(F(light)); @@ -100,7 +100,7 @@ void TestRunFunction::runLightFunction() qDebug("done"); } -void TestRunFunction::runHeavyFunction() +void tst_QtConcurrentRun::runHeavyFunction() { qDebug("starting function"); QFuture<void> future = run(F(heavy)); @@ -141,7 +141,7 @@ public: int operator()(int in) const { return in; } }; -void TestRunFunction::returnValue() +void tst_QtConcurrentRun::returnValue() { QFuture<int> f; @@ -217,7 +217,7 @@ struct TestConstClass void fooInt(int) const { }; }; -void TestRunFunction::functionObject() +void tst_QtConcurrentRun::functionObject() { QFuture<void> f; TestClass c; @@ -235,7 +235,7 @@ void TestRunFunction::functionObject() } -void TestRunFunction::memberFunctions() +void tst_QtConcurrentRun::memberFunctions() { TestClass c; @@ -278,7 +278,7 @@ void stringIntFunction(QString) } -void TestRunFunction::implicitConvertibleTypes() +void tst_QtConcurrentRun::implicitConvertibleTypes() { double d; run(F(doubleFunction), d).waitForFinished(); @@ -294,7 +294,7 @@ void TestRunFunction::implicitConvertibleTypes() void fn() { } -void TestRunFunction::runWaitLoop() +void tst_QtConcurrentRun::runWaitLoop() { for (int i = 0; i < 1000; ++i) run(fn).waitForFinished(); @@ -324,7 +324,7 @@ int recursiveResult(int level) return 1; } -void TestRunFunction::recursive() +void tst_QtConcurrentRun::recursive() { int levels = 15; @@ -375,7 +375,7 @@ int fn2(double, int *) } #if 0 -void TestRunFunction::createFunctor() +void tst_QtConcurrentRun::createFunctor() { e = 0; ::QtConcurrent::createFunctor(vfn0)(); diff --git a/tests/auto/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/tests/auto/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp index 6f586d7..23fd19b 100644 --- a/tests/auto/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp +++ b/tests/auto/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp @@ -48,7 +48,7 @@ using namespace QtConcurrent; -class tst_threadengine: public QObject +class tst_QtConcurrentThreadEngine: public QObject { Q_OBJECT public: @@ -79,7 +79,7 @@ public: } }; -void tst_threadengine::runDirectly() +void tst_QtConcurrentThreadEngine::runDirectly() { { PrintUser engine; @@ -120,7 +120,7 @@ public: bool done; }; -void tst_threadengine::result() +void tst_QtConcurrentThreadEngine::result() { StringResultUser engine; QCOMPARE(*engine.startBlocking(), QString("Foo")); @@ -147,7 +147,7 @@ public: bool done; }; -void tst_threadengine::runThroughStarter() +void tst_QtConcurrentThreadEngine::runThroughStarter() { { ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser()); @@ -180,7 +180,7 @@ public: } }; -void tst_threadengine::cancel() +void tst_QtConcurrentThreadEngine::cancel() { { CancelUser *engine = new CancelUser(); @@ -234,7 +234,7 @@ public: // Test that a user task with a thread function that always // want to be throttled still completes. The thread engine // should make keep one thread running at all times. -void tst_threadengine::throttle() +void tst_QtConcurrentThreadEngine::throttle() { const int repeats = 10; for (int i = 0; i < repeats; ++i) { @@ -280,7 +280,7 @@ public: bool finishing; }; -void tst_threadengine::threadCount() +void tst_QtConcurrentThreadEngine::threadCount() { const int repeats = 10; for (int i = 0; i < repeats; ++i) { @@ -320,7 +320,7 @@ public: }; -void tst_threadengine::multipleResults() +void tst_QtConcurrentThreadEngine::multipleResults() { MultipleResultsUser *engine = new MultipleResultsUser(); QFuture<int> f = engine->startAsynchronously(); @@ -351,7 +351,7 @@ public: } }; -void tst_threadengine::stresstest() +void tst_QtConcurrentThreadEngine::stresstest() { const int times = 20000; @@ -379,7 +379,7 @@ public: ThreadFunctionResult threadFunction() { QTest::qSleep(sleepTime); return ThreadFinished; } }; -void tst_threadengine::cancelQueuedSlowUser() +void tst_QtConcurrentThreadEngine::cancelQueuedSlowUser() { const int times = 100; @@ -436,7 +436,7 @@ public: QThread *blockThread; }; -void tst_threadengine::exceptions() +void tst_QtConcurrentThreadEngine::exceptions() { // Asynchronous mode: { @@ -527,7 +527,7 @@ void tst_threadengine::exceptions() #endif -QTEST_MAIN(tst_threadengine) +QTEST_MAIN(tst_QtConcurrentThreadEngine) #include "tst_qtconcurrentthreadengine.moc" diff --git a/tests/auto/qtransform/tst_qtransform.cpp b/tests/auto/qtransform/tst_qtransform.cpp index 827a486..a3ded8e 100644 --- a/tests/auto/qtransform/tst_qtransform.cpp +++ b/tests/auto/qtransform/tst_qtransform.cpp @@ -610,6 +610,11 @@ void tst_QTransform::types() m4.rotate(45); QCOMPARE(m4.type(), QTransform::TxRotate); + + QTransform m5; + m5.scale(5, 5); + m5 = m5.adjoint() / m5.determinant(); + QCOMPARE(m5.type(), QTransform::TxScale); } diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index e39cf6c..bdc0a0c 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -246,7 +246,7 @@ public: fetched(false), rows(0), cols(0), levels(INT_MAX), wrongIndex(false) { init(); } QtTestModel(int _rows, int _cols, QObject *parent = 0): QAbstractItemModel(parent), - rows(_rows), cols(_cols), levels(INT_MAX), wrongIndex(false) { init(); } + fetched(false), rows(_rows), cols(_cols), levels(INT_MAX), wrongIndex(false) { init(); } void init() { decorationsEnabled = false; diff --git a/tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp index 0fcde21..1c43069 100644 --- a/tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp @@ -42,6 +42,7 @@ #include <QtTest/QtTest> #include <qvarlengtharray.h> +#include <qvariant.h> const int N = 1; @@ -61,6 +62,7 @@ private slots: void removeLast(); void oldTests(); void task214223(); + void QTBUG6718_resize(); }; int fooCtor = 0; @@ -71,7 +73,7 @@ struct Foo int *p; Foo() { p = new int; ++fooCtor; } - Foo(const Foo &other) { p = new int; ++fooCtor; } + Foo(const Foo &/*other*/) { p = new int; ++fooCtor; } void operator=(const Foo & /* other */) { } @@ -244,9 +246,50 @@ void tst_QVarLengthArray::task214223() // will make the next call to append(const T&) corrupt the memory // you should get a segfault pretty soon after that :-) QVarLengthArray<float, 1> d(1); - for (int i=0; i<30; i++) + for (int i=0; i<30; i++) d.append(i); } +void tst_QVarLengthArray::QTBUG6718_resize() +{ + //MOVABLE + { + QVarLengthArray<QVariant,1> values(1); + QCOMPARE(values.size(), 1); + values[0] = 1; + values.resize(2); + QCOMPARE(values[1], QVariant()); + QCOMPARE(values[0], QVariant(1)); + values[1] = 2; + QCOMPARE(values[1], QVariant(2)); + QCOMPARE(values.size(), 2); + } + + //POD + { + QVarLengthArray<int,1> values(1); + QCOMPARE(values.size(), 1); + values[0] = 1; + values.resize(2); + QCOMPARE(values[0], 1); + values[1] = 2; + QCOMPARE(values[1], 2); + QCOMPARE(values.size(), 2); + } + + //COMPLEX + { + QVarLengthArray<QVarLengthArray<QString, 15>,1> values(1); + QCOMPARE(values.size(), 1); + values[0].resize(10); + values.resize(2); + QCOMPARE(values[1].size(), 0); + QCOMPARE(values[0].size(), 10); + values[1].resize(20); + QCOMPARE(values[1].size(), 20); + QCOMPARE(values.size(), 2); + } +} + QTEST_APPLESS_MAIN(tst_QVarLengthArray) #include "tst_qvarlengtharray.moc" diff --git a/tests/auto/qvectornd/tst_qvectornd.cpp b/tests/auto/qvectornd/tst_qvectornd.cpp index 2be7264..2850f32 100644 --- a/tests/auto/qvectornd/tst_qvectornd.cpp +++ b/tests/auto/qvectornd/tst_qvectornd.cpp @@ -45,12 +45,12 @@ #include <QtGui/qvector3d.h> #include <QtGui/qvector4d.h> -class tst_QVector : public QObject +class tst_QVectorND : public QObject { Q_OBJECT public: - tst_QVector() {} - ~tst_QVector() {} + tst_QVectorND() {} + ~tst_QVectorND() {} private slots: void create2(); @@ -155,7 +155,7 @@ static bool fuzzyCompare(qreal x, qreal y) // Test the creation of QVector2D objects in various ways: // construct, copy, and modify. -void tst_QVector::create2() +void tst_QVectorND::create2() { QVector2D null; QCOMPARE(null.x(), (qreal)0.0f); @@ -244,7 +244,7 @@ void tst_QVector::create2() // Test the creation of QVector3D objects in various ways: // construct, copy, and modify. -void tst_QVector::create3() +void tst_QVectorND::create3() { QVector3D null; QCOMPARE(null.x(), (qreal)0.0f); @@ -370,7 +370,7 @@ void tst_QVector::create3() // Test the creation of QVector4D objects in various ways: // construct, copy, and modify. -void tst_QVector::create4() +void tst_QVectorND::create4() { QVector4D null; QCOMPARE(null.x(), (qreal)0.0f); @@ -556,7 +556,7 @@ void tst_QVector::create4() } // Test vector length computation for 2D vectors. -void tst_QVector::length2_data() +void tst_QVectorND::length2_data() { QTest::addColumn<qreal>("x"); QTest::addColumn<qreal>("y"); @@ -569,7 +569,7 @@ void tst_QVector::length2_data() QTest::newRow("-1y") << (qreal)0.0f << (qreal)-1.0f << (qreal)1.0f; QTest::newRow("two") << (qreal)2.0f << (qreal)-2.0f << (qreal)qSqrt(8.0f); } -void tst_QVector::length2() +void tst_QVectorND::length2() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -581,7 +581,7 @@ void tst_QVector::length2() } // Test vector length computation for 3D vectors. -void tst_QVector::length3_data() +void tst_QVectorND::length3_data() { QTest::addColumn<qreal>("x"); QTest::addColumn<qreal>("y"); @@ -597,7 +597,7 @@ void tst_QVector::length3_data() QTest::newRow("-1z") << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f << (qreal)1.0f; QTest::newRow("two") << (qreal)2.0f << (qreal)-2.0f << (qreal)2.0f << (qreal)qSqrt(12.0f); } -void tst_QVector::length3() +void tst_QVectorND::length3() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -610,7 +610,7 @@ void tst_QVector::length3() } // Test vector length computation for 4D vectors. -void tst_QVector::length4_data() +void tst_QVectorND::length4_data() { QTest::addColumn<qreal>("x"); QTest::addColumn<qreal>("y"); @@ -629,7 +629,7 @@ void tst_QVector::length4_data() QTest::newRow("-1w") << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)-1.0f << (qreal)1.0f; QTest::newRow("two") << (qreal)2.0f << (qreal)-2.0f << (qreal)2.0f << (qreal)2.0f << (qreal)qSqrt(16.0f); } -void tst_QVector::length4() +void tst_QVectorND::length4() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -643,12 +643,12 @@ void tst_QVector::length4() } // Test the unit vector conversion for 2D vectors. -void tst_QVector::normalized2_data() +void tst_QVectorND::normalized2_data() { // Use the same test data as the length test. length2_data(); } -void tst_QVector::normalized2() +void tst_QVectorND::normalized2() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -665,12 +665,12 @@ void tst_QVector::normalized2() } // Test the unit vector conversion for 3D vectors. -void tst_QVector::normalized3_data() +void tst_QVectorND::normalized3_data() { // Use the same test data as the length test. length3_data(); } -void tst_QVector::normalized3() +void tst_QVectorND::normalized3() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -689,12 +689,12 @@ void tst_QVector::normalized3() } // Test the unit vector conversion for 4D vectors. -void tst_QVector::normalized4_data() +void tst_QVectorND::normalized4_data() { // Use the same test data as the length test. length4_data(); } -void tst_QVector::normalized4() +void tst_QVectorND::normalized4() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -715,12 +715,12 @@ void tst_QVector::normalized4() } // Test the unit vector conversion for 2D vectors. -void tst_QVector::normalize2_data() +void tst_QVectorND::normalize2_data() { // Use the same test data as the length test. length2_data(); } -void tst_QVector::normalize2() +void tst_QVectorND::normalize2() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -735,12 +735,12 @@ void tst_QVector::normalize2() } // Test the unit vector conversion for 3D vectors. -void tst_QVector::normalize3_data() +void tst_QVectorND::normalize3_data() { // Use the same test data as the length test. length3_data(); } -void tst_QVector::normalize3() +void tst_QVectorND::normalize3() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -756,12 +756,12 @@ void tst_QVector::normalize3() } // Test the unit vector conversion for 4D vectors. -void tst_QVector::normalize4_data() +void tst_QVectorND::normalize4_data() { // Use the same test data as the length test. length4_data(); } -void tst_QVector::normalize4() +void tst_QVectorND::normalize4() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -778,7 +778,7 @@ void tst_QVector::normalize4() } // Test the comparison operators for 2D vectors. -void tst_QVector::compare2() +void tst_QVectorND::compare2() { QVector2D v1(1, 2); QVector2D v2(1, 2); @@ -791,7 +791,7 @@ void tst_QVector::compare2() } // Test the comparison operators for 3D vectors. -void tst_QVector::compare3() +void tst_QVectorND::compare3() { QVector3D v1(1, 2, 4); QVector3D v2(1, 2, 4); @@ -806,7 +806,7 @@ void tst_QVector::compare3() } // Test the comparison operators for 4D vectors. -void tst_QVector::compare4() +void tst_QVectorND::compare4() { QVector4D v1(1, 2, 4, 8); QVector4D v2(1, 2, 4, 8); @@ -823,7 +823,7 @@ void tst_QVector::compare4() } // Test vector addition for 2D vectors. -void tst_QVector::add2_data() +void tst_QVectorND::add2_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -852,7 +852,7 @@ void tst_QVector::add2_data() << (qreal)4.0f << (qreal)5.0f << (qreal)5.0f << (qreal)7.0f; } -void tst_QVector::add2() +void tst_QVectorND::add2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -876,7 +876,7 @@ void tst_QVector::add2() } // Test vector addition for 3D vectors. -void tst_QVector::add3_data() +void tst_QVectorND::add3_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -913,7 +913,7 @@ void tst_QVector::add3_data() << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)5.0f << (qreal)7.0f << (qreal)-3.0f; } -void tst_QVector::add3() +void tst_QVectorND::add3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -941,7 +941,7 @@ void tst_QVector::add3() } // Test vector addition for 4D vectors. -void tst_QVector::add4_data() +void tst_QVectorND::add4_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -986,7 +986,7 @@ void tst_QVector::add4_data() << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)9.0f << (qreal)5.0f << (qreal)7.0f << (qreal)-3.0f << (qreal)17.0f; } -void tst_QVector::add4() +void tst_QVectorND::add4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1018,12 +1018,12 @@ void tst_QVector::add4() } // Test vector subtraction for 2D vectors. -void tst_QVector::subtract2_data() +void tst_QVectorND::subtract2_data() { // Use the same test data as the add test. add2_data(); } -void tst_QVector::subtract2() +void tst_QVectorND::subtract2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1055,12 +1055,12 @@ void tst_QVector::subtract2() } // Test vector subtraction for 3D vectors. -void tst_QVector::subtract3_data() +void tst_QVectorND::subtract3_data() { // Use the same test data as the add test. add3_data(); } -void tst_QVector::subtract3() +void tst_QVectorND::subtract3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1097,12 +1097,12 @@ void tst_QVector::subtract3() } // Test vector subtraction for 4D vectors. -void tst_QVector::subtract4_data() +void tst_QVectorND::subtract4_data() { // Use the same test data as the add test. add4_data(); } -void tst_QVector::subtract4() +void tst_QVectorND::subtract4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1144,7 +1144,7 @@ void tst_QVector::subtract4() } // Test component-wise vector multiplication for 2D vectors. -void tst_QVector::multiply2_data() +void tst_QVectorND::multiply2_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -1173,7 +1173,7 @@ void tst_QVector::multiply2_data() << (qreal)4.0f << (qreal)5.0f << (qreal)4.0f << (qreal)10.0f; } -void tst_QVector::multiply2() +void tst_QVectorND::multiply2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1197,7 +1197,7 @@ void tst_QVector::multiply2() } // Test component-wise vector multiplication for 3D vectors. -void tst_QVector::multiply3_data() +void tst_QVectorND::multiply3_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -1234,7 +1234,7 @@ void tst_QVector::multiply3_data() << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)4.0f << (qreal)10.0f << (qreal)-18.0f; } -void tst_QVector::multiply3() +void tst_QVectorND::multiply3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1262,7 +1262,7 @@ void tst_QVector::multiply3() } // Test component-wise vector multiplication for 4D vectors. -void tst_QVector::multiply4_data() +void tst_QVectorND::multiply4_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -1307,7 +1307,7 @@ void tst_QVector::multiply4_data() << (qreal)4.0f << (qreal)5.0f << (qreal)-6.0f << (qreal)9.0f << (qreal)4.0f << (qreal)10.0f << (qreal)-18.0f << (qreal)72.0f; } -void tst_QVector::multiply4() +void tst_QVectorND::multiply4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1339,7 +1339,7 @@ void tst_QVector::multiply4() } // Test vector multiplication by a factor for 2D vectors. -void tst_QVector::multiplyFactor2_data() +void tst_QVectorND::multiplyFactor2_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -1372,7 +1372,7 @@ void tst_QVector::multiplyFactor2_data() << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; } -void tst_QVector::multiplyFactor2() +void tst_QVectorND::multiplyFactor2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1395,7 +1395,7 @@ void tst_QVector::multiplyFactor2() } // Test vector multiplication by a factor for 3D vectors. -void tst_QVector::multiplyFactor3_data() +void tst_QVectorND::multiplyFactor3_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -1435,7 +1435,7 @@ void tst_QVector::multiplyFactor3_data() << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; } -void tst_QVector::multiplyFactor3() +void tst_QVectorND::multiplyFactor3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1461,7 +1461,7 @@ void tst_QVector::multiplyFactor3() } // Test vector multiplication by a factor for 4D vectors. -void tst_QVector::multiplyFactor4_data() +void tst_QVectorND::multiplyFactor4_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -1508,7 +1508,7 @@ void tst_QVector::multiplyFactor4_data() << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f << (qreal)0.0f; } -void tst_QVector::multiplyFactor4() +void tst_QVectorND::multiplyFactor4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1537,12 +1537,12 @@ void tst_QVector::multiplyFactor4() } // Test vector division by a factor for 2D vectors. -void tst_QVector::divide2_data() +void tst_QVectorND::divide2_data() { // Use the same test data as the multiply test. multiplyFactor2_data(); } -void tst_QVector::divide2() +void tst_QVectorND::divide2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1567,12 +1567,12 @@ void tst_QVector::divide2() } // Test vector division by a factor for 3D vectors. -void tst_QVector::divide3_data() +void tst_QVectorND::divide3_data() { // Use the same test data as the multiply test. multiplyFactor3_data(); } -void tst_QVector::divide3() +void tst_QVectorND::divide3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1600,12 +1600,12 @@ void tst_QVector::divide3() } // Test vector division by a factor for 4D vectors. -void tst_QVector::divide4_data() +void tst_QVectorND::divide4_data() { // Use the same test data as the multiply test. multiplyFactor4_data(); } -void tst_QVector::divide4() +void tst_QVectorND::divide4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1636,12 +1636,12 @@ void tst_QVector::divide4() } // Test vector negation for 2D vectors. -void tst_QVector::negate2_data() +void tst_QVectorND::negate2_data() { // Use the same test data as the add test. add2_data(); } -void tst_QVector::negate2() +void tst_QVectorND::negate2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1653,12 +1653,12 @@ void tst_QVector::negate2() } // Test vector negation for 3D vectors. -void tst_QVector::negate3_data() +void tst_QVectorND::negate3_data() { // Use the same test data as the add test. add3_data(); } -void tst_QVector::negate3() +void tst_QVectorND::negate3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1671,12 +1671,12 @@ void tst_QVector::negate3() } // Test vector negation for 4D vectors. -void tst_QVector::negate4_data() +void tst_QVectorND::negate4_data() { // Use the same test data as the add test. add4_data(); } -void tst_QVector::negate4() +void tst_QVectorND::negate4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1690,7 +1690,7 @@ void tst_QVector::negate4() } // Test the computation of vector cross-products. -void tst_QVector::crossProduct_data() +void tst_QVectorND::crossProduct_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -1721,7 +1721,7 @@ void tst_QVector::crossProduct_data() << (qreal)-3.0f << (qreal)6.0f << (qreal)-3.0f << (qreal)32.0f; } -void tst_QVector::crossProduct() +void tst_QVectorND::crossProduct() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1751,12 +1751,12 @@ void tst_QVector::crossProduct() } // Test the computation of normals. -void tst_QVector::normal_data() +void tst_QVectorND::normal_data() { // Use the same test data as the crossProduct test. crossProduct_data(); } -void tst_QVector::normal() +void tst_QVectorND::normal() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1780,7 +1780,7 @@ void tst_QVector::normal() } // Test distance to plane calculations. -void tst_QVector::distanceToPlane_data() +void tst_QVectorND::distanceToPlane_data() { QTest::addColumn<qreal>("x1"); // Point on plane QTest::addColumn<qreal>("y1"); @@ -1823,7 +1823,7 @@ void tst_QVector::distanceToPlane_data() << (qreal)0.0f << (qreal)2.0f << (qreal)0.0f << (qreal)-2.0f; } -void tst_QVector::distanceToPlane() +void tst_QVectorND::distanceToPlane() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1853,7 +1853,7 @@ void tst_QVector::distanceToPlane() } // Test distance to line calculations. -void tst_QVector::distanceToLine_data() +void tst_QVectorND::distanceToLine_data() { QTest::addColumn<qreal>("x1"); // Point on line QTest::addColumn<qreal>("y1"); @@ -1896,7 +1896,7 @@ void tst_QVector::distanceToLine_data() << (qreal)0.0f << (qreal)5.0f << (qreal)0.0f << (qreal)5.0f; } -void tst_QVector::distanceToLine() +void tst_QVectorND::distanceToLine() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1917,7 +1917,7 @@ void tst_QVector::distanceToLine() } // Test the computation of dot products for 2D vectors. -void tst_QVector::dotProduct2_data() +void tst_QVectorND::dotProduct2_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -1940,7 +1940,7 @@ void tst_QVector::dotProduct2_data() << (qreal)4.0f << (qreal)5.0f << (qreal)14.0f; } -void tst_QVector::dotProduct2() +void tst_QVectorND::dotProduct2() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1960,12 +1960,12 @@ void tst_QVector::dotProduct2() } // Test the computation of dot products for 3D vectors. -void tst_QVector::dotProduct3_data() +void tst_QVectorND::dotProduct3_data() { // Use the same test data as the crossProduct test. crossProduct_data(); } -void tst_QVector::dotProduct3() +void tst_QVectorND::dotProduct3() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -1994,7 +1994,7 @@ void tst_QVector::dotProduct3() } // Test the computation of dot products for 4D vectors. -void tst_QVector::dotProduct4_data() +void tst_QVectorND::dotProduct4_data() { QTest::addColumn<qreal>("x1"); QTest::addColumn<qreal>("y1"); @@ -2021,7 +2021,7 @@ void tst_QVector::dotProduct4_data() << (qreal)4.0f << (qreal)5.0f << (qreal)6.0f << (qreal)7.0f << (qreal)60.0f; } -void tst_QVector::dotProduct4() +void tst_QVectorND::dotProduct4() { QFETCH(qreal, x1); QFETCH(qreal, y1); @@ -2044,14 +2044,14 @@ void tst_QVector::dotProduct4() QCOMPARE(QVector4D::dotProduct(v1, v2), d); } -class tst_QVectorProperties : public QObject +class tst_QVectorNDProperties : public QObject { Q_OBJECT Q_PROPERTY(QVector2D vector2D READ vector2D WRITE setVector2D) Q_PROPERTY(QVector3D vector3D READ vector3D WRITE setVector3D) Q_PROPERTY(QVector4D vector4D READ vector4D WRITE setVector4D) public: - tst_QVectorProperties(QObject *parent = 0) : QObject(parent) {} + tst_QVectorNDProperties(QObject *parent = 0) : QObject(parent) {} QVector2D vector2D() const { return v2; } void setVector2D(const QVector2D& value) { v2 = value; } @@ -2069,9 +2069,9 @@ private: }; // Test getting and setting vector properties via the metaobject system. -void tst_QVector::properties() +void tst_QVectorND::properties() { - tst_QVectorProperties obj; + tst_QVectorNDProperties obj; obj.setVector2D(QVector2D(1.0f, 2.0f)); obj.setVector3D(QVector3D(3.0f, 4.0f, 5.0f)); @@ -2115,7 +2115,7 @@ void tst_QVector::properties() QCOMPARE(v4.w(), (qreal)-9.0f); } -void tst_QVector::metaTypes() +void tst_QVectorND::metaTypes() { QVERIFY(QMetaType::type("QVector2D") == QMetaType::QVector2D); QVERIFY(QMetaType::type("QVector3D") == QMetaType::QVector3D); @@ -2137,6 +2137,6 @@ void tst_QVector::metaTypes() QVERIFY(qMetaTypeId<QVector4D>() == QMetaType::QVector4D); } -QTEST_APPLESS_MAIN(tst_QVector) +QTEST_APPLESS_MAIN(tst_QVectorND) #include "tst_qvectornd.moc" diff --git a/tests/auto/qvideowidget/tst_qvideowidget.cpp b/tests/auto/qvideowidget/tst_qvideowidget.cpp index f703055..f1eef50 100644 --- a/tests/auto/qvideowidget/tst_qvideowidget.cpp +++ b/tests/auto/qvideowidget/tst_qvideowidget.cpp @@ -120,7 +120,7 @@ private: void color_data(); }; -Q_DECLARE_METATYPE(QVideoWidget::AspectRatioMode) +Q_DECLARE_METATYPE(Qt::AspectRatioMode) Q_DECLARE_METATYPE(const uchar *) class QtTestOutputControl : public QVideoOutputControl @@ -148,7 +148,7 @@ public: , m_brightness(0) , m_contrast(0) , m_saturation(0) - , m_aspectRatioMode(QVideoWidget::KeepAspectRatio) + , m_aspectRatioMode(Qt::KeepAspectRatio) , m_fullScreen(0) { } @@ -169,8 +169,8 @@ public: QSize nativeSize() const { return m_nativeSize; } void setNativeSize(const QSize &size) { m_nativeSize = size; emit nativeSizeChanged(); } - QVideoWidget::AspectRatioMode aspectRatioMode() const { return m_aspectRatioMode; } - void setAspectRatioMode(QVideoWidget::AspectRatioMode mode) { m_aspectRatioMode = mode; } + Qt::AspectRatioMode aspectRatioMode() const { return m_aspectRatioMode; } + void setAspectRatioMode(Qt::AspectRatioMode mode) { m_aspectRatioMode = mode; } int brightness() const { return m_brightness; } void setBrightness(int brightness) { emit brightnessChanged(m_brightness = brightness); } @@ -191,7 +191,7 @@ private: int m_contrast; int m_hue; int m_saturation; - QVideoWidget::AspectRatioMode m_aspectRatioMode; + Qt::AspectRatioMode m_aspectRatioMode; QRect m_displayRect; QSize m_nativeSize; bool m_fullScreen; @@ -205,7 +205,7 @@ public: , m_contrast(1.0) , m_hue(1.0) , m_saturation(1.0) - , m_aspectRatioMode(QVideoWidget::KeepAspectRatio) + , m_aspectRatioMode(Qt::KeepAspectRatio) , m_fullScreen(false) { } @@ -213,8 +213,8 @@ public: bool isFullScreen() const { return m_fullScreen; } void setFullScreen(bool fullScreen) { emit fullScreenChanged(m_fullScreen = fullScreen); } - QVideoWidget::AspectRatioMode aspectRatioMode() const { return m_aspectRatioMode; } - void setAspectRatioMode(QVideoWidget::AspectRatioMode mode) { m_aspectRatioMode = mode; } + Qt::AspectRatioMode aspectRatioMode() const { return m_aspectRatioMode; } + void setAspectRatioMode(Qt::AspectRatioMode mode) { m_aspectRatioMode = mode; } int brightness() const { return m_brightness; } void setBrightness(int brightness) { emit brightnessChanged(m_brightness = brightness); } @@ -245,7 +245,7 @@ private: int m_contrast; int m_hue; int m_saturation; - QVideoWidget::AspectRatioMode m_aspectRatioMode; + Qt::AspectRatioMode m_aspectRatioMode; QSize m_sizeHint; bool m_fullScreen; }; @@ -358,8 +358,8 @@ void tst_QVideoWidget::nullObject() QTest::qWaitForWindowShown(&widget); QCOMPARE(widget.isFullScreen(), true); - widget.setAspectRatioMode(QVideoWidget::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), QVideoWidget::IgnoreAspectRatio); + widget.setAspectRatioMode(Qt::IgnoreAspectRatio); + QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); { QSignalSpy spy(&widget, SIGNAL(brightnessChanged(int))); @@ -443,8 +443,8 @@ void tst_QVideoWidget::nullService() QTest::qWaitForWindowShown(&widget); QCOMPARE(widget.isFullScreen(), true); - widget.setAspectRatioMode(QVideoWidget::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), QVideoWidget::IgnoreAspectRatio); + widget.setAspectRatioMode(Qt::IgnoreAspectRatio); + QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); widget.setBrightness(100); QCOMPARE(widget.brightness(), 100); @@ -711,65 +711,65 @@ void tst_QVideoWidget::showRendererControl() void tst_QVideoWidget::aspectRatioWindowControl() { QtTestVideoObject object(new QtTestWindowControl, 0, 0); - object.testService->windowControl->setAspectRatioMode(QVideoWidget::IgnoreAspectRatio); + object.testService->windowControl->setAspectRatioMode(Qt::IgnoreAspectRatio); QVideoWidget widget; widget.setMediaObject(&object); widget.setWindowFlags(Qt::X11BypassWindowManagerHint); // Test the aspect ratio defaults to keeping the aspect ratio. - QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); + QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); // Test the control has been informed of the aspect ratio change, post show. widget.show(); QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); - QCOMPARE(object.testService->windowControl->aspectRatioMode(), QVideoWidget::KeepAspectRatio); + QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); + QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::KeepAspectRatio); // Test an aspect ratio change is enforced immediately while visible. - widget.setAspectRatioMode(QVideoWidget::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), QVideoWidget::IgnoreAspectRatio); - QCOMPARE(object.testService->windowControl->aspectRatioMode(), QVideoWidget::IgnoreAspectRatio); + widget.setAspectRatioMode(Qt::IgnoreAspectRatio); + QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); + QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::IgnoreAspectRatio); // Test an aspect ratio set while not visible is respected. widget.hide(); - widget.setAspectRatioMode(QVideoWidget::KeepAspectRatio); - QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); + widget.setAspectRatioMode(Qt::KeepAspectRatio); + QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); widget.show(); - QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); - QCOMPARE(object.testService->windowControl->aspectRatioMode(), QVideoWidget::KeepAspectRatio); + QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); + QCOMPARE(object.testService->windowControl->aspectRatioMode(), Qt::KeepAspectRatio); } void tst_QVideoWidget::aspectRatioWidgetControl() { QtTestVideoObject object(0, new QtTestWidgetControl, 0); - object.testService->widgetControl->setAspectRatioMode(QVideoWidget::IgnoreAspectRatio); + object.testService->widgetControl->setAspectRatioMode(Qt::IgnoreAspectRatio); QVideoWidget widget; widget.setMediaObject(&object); widget.setWindowFlags(Qt::X11BypassWindowManagerHint); // Test the aspect ratio defaults to keeping the aspect ratio. - QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); + QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); // Test the control has been informed of the aspect ratio change, post show. widget.show(); QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); - QCOMPARE(object.testService->widgetControl->aspectRatioMode(), QVideoWidget::KeepAspectRatio); + QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); + QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::KeepAspectRatio); // Test an aspect ratio change is enforced immediately while visible. - widget.setAspectRatioMode(QVideoWidget::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), QVideoWidget::IgnoreAspectRatio); - QCOMPARE(object.testService->widgetControl->aspectRatioMode(), QVideoWidget::IgnoreAspectRatio); + widget.setAspectRatioMode(Qt::IgnoreAspectRatio); + QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); + QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::IgnoreAspectRatio); // Test an aspect ratio set while not visible is respected. widget.hide(); - widget.setAspectRatioMode(QVideoWidget::KeepAspectRatio); - QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); + widget.setAspectRatioMode(Qt::KeepAspectRatio); + QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); widget.show(); - QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); - QCOMPARE(object.testService->widgetControl->aspectRatioMode(), QVideoWidget::KeepAspectRatio); + QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); + QCOMPARE(object.testService->widgetControl->aspectRatioMode(), Qt::KeepAspectRatio); } void tst_QVideoWidget::aspectRatioRendererControl() @@ -781,23 +781,23 @@ void tst_QVideoWidget::aspectRatioRendererControl() widget.setWindowFlags(Qt::X11BypassWindowManagerHint); // Test the aspect ratio defaults to keeping the aspect ratio. - QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); + QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); // Test the control has been informed of the aspect ratio change, post show. widget.show(); QTest::qWaitForWindowShown(&widget); - QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); + QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); // Test an aspect ratio change is enforced immediately while visible. - widget.setAspectRatioMode(QVideoWidget::IgnoreAspectRatio); - QCOMPARE(widget.aspectRatioMode(), QVideoWidget::IgnoreAspectRatio); + widget.setAspectRatioMode(Qt::IgnoreAspectRatio); + QCOMPARE(widget.aspectRatioMode(), Qt::IgnoreAspectRatio); // Test an aspect ratio set while not visible is respected. widget.hide(); - widget.setAspectRatioMode(QVideoWidget::KeepAspectRatio); - QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); + widget.setAspectRatioMode(Qt::KeepAspectRatio); + QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); widget.show(); - QCOMPARE(widget.aspectRatioMode(), QVideoWidget::KeepAspectRatio); + QCOMPARE(widget.aspectRatioMode(), Qt::KeepAspectRatio); } void tst_QVideoWidget::sizeHint_data() diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index abd9604..76e20b9 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -402,6 +402,7 @@ private slots: void scrollWithoutBackingStore(); void taskQTBUG_7532_tabOrderWithFocusProxy(); + void movedAndResizedAttributes(); private: bool ensureScreenSize(int width, int height); @@ -10040,5 +10041,61 @@ void tst_QWidget::taskQTBUG_7532_tabOrderWithFocusProxy() // No Q_ASSERT, then it's allright. } +void tst_QWidget::movedAndResizedAttributes() +{ +#if defined (Q_OS_MAC) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN) + QEXPECT_FAIL("", "FixMe, QTBUG-8941 and QTBUG-8977", Abort); + QVERIFY(false); +#else + QWidget w; + w.show(); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.setWindowState(Qt::WindowFullScreen); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.setWindowState(Qt::WindowMaximized); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.setWindowState(Qt::WindowMinimized); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.showNormal(); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.showMaximized(); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.showFullScreen(); + + QVERIFY(!w.testAttribute(Qt::WA_Moved)); + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.showNormal(); + w.move(10,10); + QVERIFY(w.testAttribute(Qt::WA_Moved)); +#if defined(Q_OS_WIN) + QEXPECT_FAIL("", "FixMe, QTBUG-8911", Abort); +#endif + QVERIFY(!w.testAttribute(Qt::WA_Resized)); + + w.resize(100, 100); + QVERIFY(w.testAttribute(Qt::WA_Moved)); + QVERIFY(w.testAttribute(Qt::WA_Resized)); +#endif +} + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" diff --git a/tests/auto/qzip/tst_qzip.cpp b/tests/auto/qzip/tst_qzip.cpp index d7fc2f7..cb3acf5 100644 --- a/tests/auto/qzip/tst_qzip.cpp +++ b/tests/auto/qzip/tst_qzip.cpp @@ -77,6 +77,7 @@ void tst_QZip::basicUnpack() QCOMPARE(files.count(), 2); QZipReader::FileInfo fi = files.at(0); + QVERIFY(fi.isValid()); QCOMPARE(fi.filePath, QString("test/")); QCOMPARE(uint(fi.isDir), (uint) 1); QCOMPARE(uint(fi.isFile), (uint) 0); @@ -85,7 +86,10 @@ void tst_QZip::basicUnpack() QCOMPARE(fi.permissions,QFile::Permissions( QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner | QFile::ReadUser | QFile::WriteUser | QFile::ExeUser )); + QCOMPARE(fi.lastModified, QDateTime::fromString("2005.11.11 13:08:02", "yyyy.MM.dd HH:mm:ss")); + fi = files.at(1); + QVERIFY(fi.isValid()); QCOMPARE(fi.filePath, QString("test/test.txt")); QCOMPARE(uint(fi.isDir), (uint) 0); QCOMPARE(uint(fi.isFile), (uint) 1); @@ -94,7 +98,12 @@ void tst_QZip::basicUnpack() QVERIFY(fi.permissions == QFile::Permissions( QFile::ReadOwner | QFile::WriteOwner | QFile::ReadUser | QFile::WriteUser )); + QCOMPARE(fi.lastModified, QDateTime::fromString("2005.11.11 13:08:02", "yyyy.MM.dd HH:mm:ss")); + QCOMPARE(zip.fileData("test/test.txt"), QByteArray("content\n")); + + fi = files.at(-1); + QVERIFY(!fi.isValid()); } void tst_QZip::symlinks() @@ -104,6 +113,7 @@ void tst_QZip::symlinks() QCOMPARE(files.count(), 2); QZipReader::FileInfo fi = files.at(0); + QVERIFY(fi.isValid()); QCOMPARE(fi.filePath, QString("symlink")); QVERIFY(!fi.isDir); QVERIFY(!fi.isFile); @@ -112,6 +122,7 @@ void tst_QZip::symlinks() QCOMPARE(zip.fileData("symlink"), QByteArray("destination")); fi = files.at(1); + QVERIFY(fi.isValid()); QCOMPARE(fi.filePath, QString("destination")); QVERIFY(!fi.isDir); QVERIFY(fi.isFile); diff --git a/tests/auto/xmlpatterns.pro b/tests/auto/xmlpatterns.pro index f670266..923f2c4 100644 --- a/tests/auto/xmlpatterns.pro +++ b/tests/auto/xmlpatterns.pro @@ -37,6 +37,7 @@ xmlpatternsdiagnosticsts.depends = xmlpatternssdk xmlpatternsview.depends = xmlpatternssdk xmlpatternsxslts.depends = xmlpatternssdk xmlpatternsschemats.depends = xmlpatternssdk +xmlpatternsxqts.depends = xmlpatternssdk !contains(QT_CONFIG, private_tests): SUBDIRS -= \ xmlpatternsdiagnosticsts \ diff --git a/tests/auto/xmlpatternsdiagnosticsts/tst_xmlpatternsdiagnosticsts.cpp b/tests/auto/xmlpatternsdiagnosticsts/tst_xmlpatternsdiagnosticsts.cpp index 4a11404..f4f6181 100644 --- a/tests/auto/xmlpatternsdiagnosticsts/tst_xmlpatternsdiagnosticsts.cpp +++ b/tests/auto/xmlpatternsdiagnosticsts/tst_xmlpatternsdiagnosticsts.cpp @@ -52,25 +52,25 @@ \since 4.5 \brief Test QtXmlPatterns test suite driver in tests/auto/xmlpatternsxqts/lib/. */ -class tst_XmlPatternsXSLTS : public tst_SuiteTest +class tst_XmlPatternsDiagnosticsTS : public tst_SuiteTest { Q_OBJECT public: - tst_XmlPatternsXSLTS(); + tst_XmlPatternsDiagnosticsTS(); protected: virtual void catalogPath(QString &write) const; }; -tst_XmlPatternsXSLTS::tst_XmlPatternsXSLTS() : tst_SuiteTest(tst_SuiteTest::XQuerySuite, true) +tst_XmlPatternsDiagnosticsTS::tst_XmlPatternsDiagnosticsTS() : tst_SuiteTest(tst_SuiteTest::XQuerySuite, true) { } -void tst_XmlPatternsXSLTS::catalogPath(QString &write) const +void tst_XmlPatternsDiagnosticsTS::catalogPath(QString &write) const { write = QLatin1String("TestSuite/DiagnosticsCatalog.xml"); } -QTEST_MAIN(tst_XmlPatternsXSLTS) +QTEST_MAIN(tst_XmlPatternsDiagnosticsTS) #include "tst_xmlpatternsdiagnosticsts.moc" #else diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-datatype.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-datatype.xsd new file mode 100644 index 0000000..60f3e4f --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-datatype.xsd @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://qt.nokia.com/test" targetNamespace="http://qt.nokia.com/test"> + <xsd:simpleType name="testType"> + <xsd:list itemType="xsd:int" /> + </xsd:simpleType> +</xsd:schema> diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-import-a.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-import-a.xsd new file mode 100644 index 0000000..e6da433 --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-import-a.xsd @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://qt.nokia.com/test" targetNamespace="http://qt.nokia.com/test"> + <xsd:import schemaLocation="indirect-import-b.xsd" namespace="http://qt.nokia.com/test2" /> + <xsd:import schemaLocation="indirect-import-c.xsd" namespace="http://qt.nokia.com/test2" /> +</xsd:schema> diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-import-b.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-import-b.xsd new file mode 100644 index 0000000..88be377 --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-import-b.xsd @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://qt.nokia.com/test" targetNamespace="http://qt.nokia.com/test2"> + <xsd:import schemaLocation="indirect-datatype.xsd" namespace="http://qt.nokia.com/test" /> +</xsd:schema> diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-import-c.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-import-c.xsd new file mode 100644 index 0000000..88be377 --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-import-c.xsd @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://qt.nokia.com/test" targetNamespace="http://qt.nokia.com/test2"> + <xsd:import schemaLocation="indirect-datatype.xsd" namespace="http://qt.nokia.com/test" /> +</xsd:schema> diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-include-a.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-include-a.xsd new file mode 100644 index 0000000..02ca5c5 --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-include-a.xsd @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://qt.nokia.com/test" targetNamespace="http://qt.nokia.com/test"> + <xsd:include schemaLocation="indirect-include-b.xsd" /> + <xsd:include schemaLocation="indirect-include-c.xsd" /> +</xsd:schema> diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-include-b.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-include-b.xsd new file mode 100644 index 0000000..efaba74 --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-include-b.xsd @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://qt.nokia.com/test" targetNamespace="http://qt.nokia.com/test"> + <xsd:include schemaLocation="indirect-datatype.xsd" /> +</xsd:schema> diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-include-c.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-include-c.xsd new file mode 100644 index 0000000..efaba74 --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-include-c.xsd @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://qt.nokia.com/test" targetNamespace="http://qt.nokia.com/test"> + <xsd:include schemaLocation="indirect-datatype.xsd" /> +</xsd:schema> diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-redefine-a.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-redefine-a.xsd new file mode 100644 index 0000000..4f0804c --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-redefine-a.xsd @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://qt.nokia.com/test" targetNamespace="http://qt.nokia.com/test"> + <xsd:redefine schemaLocation="indirect-redefine-b.xsd" /> + <xsd:redefine schemaLocation="indirect-redefine-c.xsd" /> +</xsd:schema> diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-redefine-b.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-redefine-b.xsd new file mode 100644 index 0000000..019a127 --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-redefine-b.xsd @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://qt.nokia.com/test" targetNamespace="http://qt.nokia.com/test"> + <xsd:redefine schemaLocation="indirect-datatype.xsd" /> +</xsd:schema> diff --git a/tests/auto/xmlpatternsvalidator/files/indirect-redefine-c.xsd b/tests/auto/xmlpatternsvalidator/files/indirect-redefine-c.xsd new file mode 100644 index 0000000..019a127 --- /dev/null +++ b/tests/auto/xmlpatternsvalidator/files/indirect-redefine-c.xsd @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://qt.nokia.com/test" targetNamespace="http://qt.nokia.com/test"> + <xsd:redefine schemaLocation="indirect-datatype.xsd" /> +</xsd:schema> diff --git a/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp b/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp index 6d4ed69..7aab47f 100644 --- a/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp +++ b/tests/auto/xmlpatternsvalidator/tst_xmlpatternsvalidator.cpp @@ -196,6 +196,21 @@ void tst_XmlPatternsValidator::xsdSupport_data() const << 1 << (QStringList() << QLatin1String("files/instance.xml")) << QString(); + + QTest::newRow("A schema with an indirectly included type") + << 0 + << (QStringList() << QLatin1String("files/indirect-include-a.xsd")) + << QString(); + + QTest::newRow("A schema with an indirectly imported type") + << 0 + << (QStringList() << QLatin1String("files/indirect-import-a.xsd")) + << QString(); + + QTest::newRow("A schema with an indirectly redefined type") + << 0 + << (QStringList() << QLatin1String("files/indirect-redefine-a.xsd")) + << QString(); } QTEST_MAIN(tst_XmlPatternsValidator) diff --git a/tests/benchmarks/corelib/codecs/qtextcodec/qtextcodec.pro b/tests/benchmarks/corelib/codecs/qtextcodec/qtextcodec.pro index 3167f26..23f0e00 100644 --- a/tests/benchmarks/corelib/codecs/qtextcodec/qtextcodec.pro +++ b/tests/benchmarks/corelib/codecs/qtextcodec/qtextcodec.pro @@ -1,5 +1,5 @@ load(qttest_p4) -TARGET = tst_qtextcodec +TARGET = tst_bench_qtextcodec QT -= gui SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro b/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro index e06d746..320746c 100755 --- a/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro +++ b/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qdiriterator +TARGET = tst_bench_qdiriterator DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/io/qfile/qfile.pro b/tests/benchmarks/corelib/io/qfile/qfile.pro index 99505c3..8663cab 100644 --- a/tests/benchmarks/corelib/io/qfile/qfile.pro +++ b/tests/benchmarks/corelib/io/qfile/qfile.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qfile +TARGET = tst_bench_qfile QT -= gui win32: DEFINES+= _CRT_SECURE_NO_WARNINGS diff --git a/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro b/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro index eca619f..3edf6a6 100644 --- a/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro +++ b/tests/benchmarks/corelib/io/qfileinfo/qfileinfo.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qfileinfo +TARGET = tst_bench_qfileinfo DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/io/qiodevice/qiodevice.pro b/tests/benchmarks/corelib/io/qiodevice/qiodevice.pro index 749a4d6..2e0f6a1 100755 --- a/tests/benchmarks/corelib/io/qiodevice/qiodevice.pro +++ b/tests/benchmarks/corelib/io/qiodevice/qiodevice.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qiodevice +TARGET = tst_bench_qiodevice TARGET.EPOCHEAPSIZE = 0x100000 0x2000000 DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro b/tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro index c1b04f4..74fd534 100644 --- a/tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro +++ b/tests/benchmarks/corelib/io/qtemporaryfile/qtemporaryfile.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qtemporaryfile +TARGET = tst_bench_qtemporaryfile DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/io/qurl/main.cpp b/tests/benchmarks/corelib/io/qurl/main.cpp new file mode 100644 index 0000000..49ace64 --- /dev/null +++ b/tests/benchmarks/corelib/io/qurl/main.cpp @@ -0,0 +1,244 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 <qurl.h> +#include <qtest.h> + +class tst_qurl: public QObject +{ + Q_OBJECT + +private slots: + void emptyUrl(); + void relativeUrl(); + void absoluteUrl(); + void isRelative_data(); + void isRelative(); + void toLocalFile_data(); + void toLocalFile(); + void toString_data(); + void toString(); + void toEncoded_data(); + void toEncoded(); + void resolved_data(); + void resolved(); + void equality_data(); + void equality(); + void qmlPropertyWriteUseCase(); + +private: + void generateFirstRunData(); +}; + +void tst_qurl::emptyUrl() +{ + QBENCHMARK { + QUrl url; + } +} + +void tst_qurl::relativeUrl() +{ + QBENCHMARK { + QUrl url("pics/avatar.png"); + } +} + +void tst_qurl::absoluteUrl() +{ + QBENCHMARK { + QUrl url("/tmp/avatar.png"); + } +} + +void tst_qurl::generateFirstRunData() +{ + QTest::addColumn<bool>("firstRun"); + + QTest::newRow("construction + first run") << true; + QTest::newRow("subsequent runs") << false; +} + +void tst_qurl::isRelative_data() +{ + generateFirstRunData(); +} + +void tst_qurl::isRelative() +{ + QFETCH(bool, firstRun); + if (firstRun) { + QBENCHMARK { + QUrl url("pics/avatar.png"); + url.isRelative(); + } + } else { + QUrl url("pics/avatar.png"); + QBENCHMARK { + url.isRelative(); + } + } +} + +void tst_qurl::toLocalFile_data() +{ + generateFirstRunData(); +} + +void tst_qurl::toLocalFile() +{ + QFETCH(bool, firstRun); + if (firstRun) { + QBENCHMARK { + QUrl url("/tmp/avatar.png"); + url.toLocalFile(); + } + } else { + QUrl url("/tmp/avatar.png"); + QBENCHMARK { + url.toLocalFile(); + } + } +} + +void tst_qurl::toString_data() +{ + generateFirstRunData(); +} + +void tst_qurl::toString() +{ + QFETCH(bool, firstRun); + if(firstRun) { + QBENCHMARK { + QUrl url("pics/avatar.png"); + url.toString(); + } + } else { + QUrl url("pics/avatar.png"); + QBENCHMARK { + url.toString(); + } + } +} + +void tst_qurl::toEncoded_data() +{ + generateFirstRunData(); +} + +void tst_qurl::toEncoded() +{ + QFETCH(bool, firstRun); + if(firstRun) { + QBENCHMARK { + QUrl url("pics/avatar.png"); + url.toEncoded(QUrl::FormattingOption(0x100)); + } + } else { + QUrl url("pics/avatar.png"); + QBENCHMARK { + url.toEncoded(QUrl::FormattingOption(0x100)); + } + } +} + +void tst_qurl::resolved_data() +{ + generateFirstRunData(); +} + +void tst_qurl::resolved() +{ + QFETCH(bool, firstRun); + if(firstRun) { + QBENCHMARK { + QUrl baseUrl("/home/user/"); + QUrl url("pics/avatar.png"); + baseUrl.resolved(url); + } + } else { + QUrl baseUrl("/home/user/"); + QUrl url("pics/avatar.png"); + QBENCHMARK { + baseUrl.resolved(url); + } + } +} + +void tst_qurl::equality_data() +{ + generateFirstRunData(); +} + +void tst_qurl::equality() +{ + QFETCH(bool, firstRun); + if(firstRun) { + QBENCHMARK { + QUrl url("pics/avatar.png"); + QUrl url2("pics/avatar2.png"); + //url == url2; + } + } else { + QUrl url("pics/avatar.png"); + QUrl url2("pics/avatar2.png"); + QBENCHMARK { + url == url2; + } + } +} + +void tst_qurl::qmlPropertyWriteUseCase() +{ + QUrl base("file:///home/user/qt/demos/declarative/samegame/SamegameCore/"); + QString str("pics/redStar.png"); + + QBENCHMARK { + QUrl u = QUrl(str); + if (!u.isEmpty() && u.isRelative()) + u = base.resolved(u); + } +} + +QTEST_MAIN(tst_qurl) + +#include "main.moc" diff --git a/tests/benchmarks/corelib/io/qurl/qurl.pro b/tests/benchmarks/corelib/io/qurl/qurl.pro new file mode 100644 index 0000000..1d2d35e --- /dev/null +++ b/tests/benchmarks/corelib/io/qurl/qurl.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qurl +QT -= gui +win32: DEFINES+= _CRT_SECURE_NO_WARNINGS + +SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/kernel/events/events.pro b/tests/benchmarks/corelib/kernel/events/events.pro index adf2317..43a7131 100644 --- a/tests/benchmarks/corelib/kernel/events/events.pro +++ b/tests/benchmarks/corelib/kernel/events/events.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_events +TARGET = tst_bench_events DEPENDPATH += . INCLUDEPATH += . # Input diff --git a/tests/benchmarks/corelib/kernel/qmetaobject/qmetaobject.pro b/tests/benchmarks/corelib/kernel/qmetaobject/qmetaobject.pro index 78300f6..a02273f 100644 --- a/tests/benchmarks/corelib/kernel/qmetaobject/qmetaobject.pro +++ b/tests/benchmarks/corelib/kernel/qmetaobject/qmetaobject.pro @@ -1,5 +1,5 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qmetaobject +TARGET = tst_bench_qmetaobject SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/kernel/qobject/qobject.pro b/tests/benchmarks/corelib/kernel/qobject/qobject.pro index 2855de4..1baaf58 100644 --- a/tests/benchmarks/corelib/kernel/qobject/qobject.pro +++ b/tests/benchmarks/corelib/kernel/qobject/qobject.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qobject +TARGET = tst_bench_qobject DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/kernel/qvariant/qvariant.pro b/tests/benchmarks/corelib/kernel/qvariant/qvariant.pro index 63b5442..f3dd66a 100644 --- a/tests/benchmarks/corelib/kernel/qvariant/qvariant.pro +++ b/tests/benchmarks/corelib/kernel/qvariant/qvariant.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qvariant +TARGET = tst_bench_qvariant DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro b/tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro index f9c1978..654b7b6 100644 --- a/tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro +++ b/tests/benchmarks/corelib/thread/qthreadstorage/qthreadstorage.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qthreadstorage +TARGET = tst_bench_qthreadstorage SOURCES += tst_qthreadstorage.cpp diff --git a/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro b/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro index c6f3fa6..3e3bf2b 100644 --- a/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro +++ b/tests/benchmarks/corelib/tools/containers-associative/containers-associative.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_containers-associative +TARGET = tst_bench_containers-associative DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro b/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro index bf6db44..4236b35 100644 --- a/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro +++ b/tests/benchmarks/corelib/tools/containers-sequential/containers-sequential.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_containers-sequential +TARGET = tst_bench_containers-sequential DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro b/tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro index a0bf021..3474dd0 100755 --- a/tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro +++ b/tests/benchmarks/corelib/tools/qbytearray/qbytearray.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qbytearray +TARGET = tst_bench_qbytearray DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/tools/qrect/qrect.pro b/tests/benchmarks/corelib/tools/qrect/qrect.pro index 6e35119..4bd05aa 100644 --- a/tests/benchmarks/corelib/tools/qrect/qrect.pro +++ b/tests/benchmarks/corelib/tools/qrect/qrect.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qrect +TARGET = tst_bench_qrect DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/tools/qregexp/qregexp.pro b/tests/benchmarks/corelib/tools/qregexp/qregexp.pro index 83d723c..e0f47c9 100644 --- a/tests/benchmarks/corelib/tools/qregexp/qregexp.pro +++ b/tests/benchmarks/corelib/tools/qregexp/qregexp.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qregexp +TARGET = tst_bench_qregexp DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/corelib/tools/qstring/qstring.pro b/tests/benchmarks/corelib/tools/qstring/qstring.pro index 2e7c86a..fa4310e 100644 --- a/tests/benchmarks/corelib/tools/qstring/qstring.pro +++ b/tests/benchmarks/corelib/tools/qstring/qstring.pro @@ -1,5 +1,5 @@ load(qttest_p4) -TARGET = tst_qstring +TARGET = tst_bench_qstring QT -= gui SOURCES += main.cpp diff --git a/tests/benchmarks/corelib/tools/qstringbuilder/qstringbuilder.pro b/tests/benchmarks/corelib/tools/qstringbuilder/qstringbuilder.pro index 79171b4..948657e 100644 --- a/tests/benchmarks/corelib/tools/qstringbuilder/qstringbuilder.pro +++ b/tests/benchmarks/corelib/tools/qstringbuilder/qstringbuilder.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qstringbuilder +TARGET = tst_bench_qstringbuilder QMAKE_CXXFLAGS += -g QMAKE_CFLAGS += -g diff --git a/tests/benchmarks/corelib/tools/qstringlist/qstringlist.pro b/tests/benchmarks/corelib/tools/qstringlist/qstringlist.pro index 5c64b34..06a5836 100644 --- a/tests/benchmarks/corelib/tools/qstringlist/qstringlist.pro +++ b/tests/benchmarks/corelib/tools/qstringlist/qstringlist.pro @@ -1,5 +1,5 @@ load(qttest_p4) -TARGET = tst_qstringlist +TARGET = tst_bench_qstringlist CONFIG -= debug CONFIG += release QT -= gui diff --git a/tests/benchmarks/declarative/binding/testtypes.cpp b/tests/benchmarks/declarative/binding/testtypes.cpp index 043c8ab..1fc9ccd 100644 --- a/tests/benchmarks/declarative/binding/testtypes.cpp +++ b/tests/benchmarks/declarative/binding/testtypes.cpp @@ -42,5 +42,5 @@ void registerTypes() { - QML_REGISTER_TYPE(Test, 1, 0, MyQmlObject, MyQmlObject); + qmlRegisterType<MyQmlObject>("Test", 1, 0, "MyQmlObject"); } diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp index 5b0004f..7aec32a 100644 --- a/tests/benchmarks/declarative/creation/tst_creation.cpp +++ b/tests/benchmarks/declarative/creation/tst_creation.cpp @@ -47,6 +47,7 @@ #include <QGraphicsScene> #include <QGraphicsItem> #include <QDeclarativeItem> +#include <QDeclarativeContext> #include <private/qobject_p.h> #ifdef Q_OS_SYMBIAN @@ -59,7 +60,7 @@ class tst_creation : public QObject { Q_OBJECT public: - tst_creation() {} + tst_creation(); private slots: void qobject_cpp(); @@ -67,13 +68,11 @@ private slots: void qobject_qmltype(); void qobject_alloc(); - void objects_qmltype_data(); - void objects_qmltype(); + void qobject_10flat_qml(); + void qobject_10flat_cpp(); - void qgraphicsitem(); - void qgraphicsobject(); - void qgraphicsitem14(); - void qgraphicsitem_tree14(); + void qobject_10tree_qml(); + void qobject_10tree_cpp(); void itemtree_notree_cpp(); void itemtree_objtree_cpp(); @@ -82,10 +81,36 @@ private slots: void itemtree_qml(); void itemtree_scene_cpp(); + void elements_data(); + void elements(); + private: QDeclarativeEngine engine; }; +class TestType : public QObject +{ +Q_OBJECT +Q_PROPERTY(QDeclarativeListProperty<QObject> resources READ resources); +Q_CLASSINFO("DefaultProperty", "resources"); +public: + TestType(QObject *parent = 0) + : QObject(parent) {} + + QDeclarativeListProperty<QObject> resources() { + return QDeclarativeListProperty<QObject>(this, 0, resources_append); + } + + static void resources_append(QDeclarativeListProperty<QObject> *p, QObject *o) { + o->setParent(p->object); + } +}; + +tst_creation::tst_creation() +{ + qmlRegisterType<TestType>("Qt.test", 1, 0, "TestType"); +} + inline QUrl TEST_FILE(const QString &filename) { return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); @@ -101,7 +126,8 @@ void tst_creation::qobject_cpp() void tst_creation::qobject_qml() { - QDeclarativeComponent component(&engine, TEST_FILE("qobject.qml")); + QDeclarativeComponent component(&engine); + component.setData("import Qt 4.6\nQtObject {}", QUrl()); QObject *obj = component.create(); delete obj; @@ -111,60 +137,73 @@ void tst_creation::qobject_qml() } } -void tst_creation::qobject_qmltype() +void tst_creation::qobject_10flat_qml() { - QDeclarativeType *t = QDeclarativeMetaType::qmlType("Qt/QtObject", 4, 6); + QDeclarativeComponent component(&engine); + component.setData("import Qt.test 1.0\nTestType { resources: [ TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{} ] }", QUrl()); + QObject *obj = component.create(); + delete obj; QBENCHMARK { - QObject *obj = t->create(); + QObject *obj = component.create(); delete obj; } } -struct QObjectFakeData { - char data[sizeof(QObjectPrivate)]; -}; - -struct QObjectFake { - QObjectFake(); - virtual ~QObjectFake(); -private: - QObjectFakeData *d; -}; - -QObjectFake::QObjectFake() +void tst_creation::qobject_10flat_cpp() { - d = new QObjectFakeData; + QBENCHMARK { + QObject *item = new TestType; + new TestType(item); + new TestType(item); + new TestType(item); + new TestType(item); + new TestType(item); + new TestType(item); + new TestType(item); + new TestType(item); + new TestType(item); + new TestType(item); + delete item; + } } -QObjectFake::~QObjectFake() +void tst_creation::qobject_10tree_qml() { - delete d; -} + QDeclarativeComponent component(&engine); + component.setData("import Qt.test 1.0\nTestType { TestType{ TestType { TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ } } } } } } } } } } }", QUrl()); + + QObject *obj = component.create(); + delete obj; -void tst_creation::qobject_alloc() -{ QBENCHMARK { - QObjectFake *obj = new QObjectFake; + QObject *obj = component.create(); delete obj; } } -void tst_creation::objects_qmltype_data() +void tst_creation::qobject_10tree_cpp() { - QTest::addColumn<QByteArray>("type"); - - QList<QByteArray> types = QDeclarativeMetaType::qmlTypeNames(); - foreach (QByteArray type, types) - QTest::newRow(type.constData()) << type; + QBENCHMARK { + QObject *item = new TestType; + QObject *root = item; + item = new TestType(item); + item = new TestType(item); + item = new TestType(item); + item = new TestType(item); + item = new TestType(item); + item = new TestType(item); + item = new TestType(item); + item = new TestType(item); + item = new TestType(item); + item = new TestType(item); + delete root; + } } -void tst_creation::objects_qmltype() +void tst_creation::qobject_qmltype() { - QFETCH(QByteArray, type); - QDeclarativeType *t = QDeclarativeMetaType::qmlType(type, 4, 6); - if (!t || !t->isCreatable()) - QSKIP("Non-creatable type", SkipSingle); + QDeclarativeType *t = QDeclarativeMetaType::qmlType("Qt/QtObject", 4, 6); QBENCHMARK { QObject *obj = t->create(); @@ -172,114 +211,32 @@ void tst_creation::objects_qmltype() } } -class QGraphicsItemDummy : public QGraphicsItem -{ -public: - virtual QRectF boundingRect() const { return QRectF(); } - virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) {} +struct QObjectFakeData { + char data[sizeof(QObjectPrivate)]; }; -class QGraphicsObjectDummy : public QGraphicsObject -{ -public: - virtual QRectF boundingRect() const { return QRectF(); } - virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) {} +struct QObjectFake { + QObjectFake(); + virtual ~QObjectFake(); +private: + QObjectFakeData *d; }; -void tst_creation::qgraphicsitem() -{ - QBENCHMARK { - QGraphicsItemDummy *i = new QGraphicsItemDummy(); - delete i; - } -} - -void tst_creation::qgraphicsobject() +QObjectFake::QObjectFake() { - QBENCHMARK { - QGraphicsObjectDummy *i = new QGraphicsObjectDummy(); - delete i; - } + d = new QObjectFakeData; } -void tst_creation::qgraphicsitem14() +QObjectFake::~QObjectFake() { - QBENCHMARK { - QGraphicsItemDummy *i1 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i2 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i3 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i4 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i5 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i6 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i7 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i8 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i9 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i10 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i11 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i12 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i13 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i14 = new QGraphicsItemDummy(); - - delete i1; - delete i2; - delete i3; - delete i4; - delete i5; - delete i6; - delete i7; - delete i8; - delete i9; - delete i10; - delete i11; - delete i12; - delete i13; - delete i14; - } + delete d; } -void tst_creation::qgraphicsitem_tree14() +void tst_creation::qobject_alloc() { QBENCHMARK { - // i1 - // +-------------------------+ - // i2 i3 - // +-----------+ +-----+-----+ - // i4 i5 i6 i7 - // +----+ +--+ +--+--+ +----+ - // i8 i9 i10 i11 i12 i13 i14 - - QGraphicsItemDummy *i1 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i2 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i3 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i4 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i5 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i6 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i7 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i8 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i9 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i10 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i11 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i12 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i13 = new QGraphicsItemDummy(); - QGraphicsItemDummy *i14 = new QGraphicsItemDummy(); - - i14->setParentItem(i7); - i13->setParentItem(i7); - i12->setParentItem(i6); - i11->setParentItem(i6); - i10->setParentItem(i5); - i9->setParentItem(i4); - i8->setParentItem(i4); - - i7->setParentItem(i3); - i6->setParentItem(i3); - i5->setParentItem(i2); - i4->setParentItem(i2); - - i3->setParentItem(i1); - i2->setParentItem(i1); - - delete i1; + QObjectFake *obj = new QObjectFake; + delete obj; } } @@ -378,6 +335,27 @@ void tst_creation::itemtree_scene_cpp() delete root; } +void tst_creation::elements_data() +{ + QTest::addColumn<QByteArray>("type"); + + QList<QByteArray> types = QDeclarativeMetaType::qmlTypeNames(); + foreach (QByteArray type, types) + QTest::newRow(type.constData()) << type; +} + +void tst_creation::elements() +{ + QFETCH(QByteArray, type); + QDeclarativeType *t = QDeclarativeMetaType::qmlType(type, 4, 6); + if (!t || !t->isCreatable()) + QSKIP("Non-creatable type", SkipSingle); + + QBENCHMARK { + QObject *obj = t->create(); + delete obj; + } +} QTEST_MAIN(tst_creation) diff --git a/tests/benchmarks/declarative/declarative.pro b/tests/benchmarks/declarative/declarative.pro index 8c0ed42..38ea6c4 100644 --- a/tests/benchmarks/declarative/declarative.pro +++ b/tests/benchmarks/declarative/declarative.pro @@ -2,9 +2,10 @@ TEMPLATE = subdirs SUBDIRS += \ binding \ creation \ + painting \ pointers \ qdeclarativecomponent \ qdeclarativeimage \ qdeclarativemetaproperty \ script \ -# qdeclarativetime + qdeclarativetime diff --git a/tests/benchmarks/declarative/painting/paintbenchmark.pro b/tests/benchmarks/declarative/painting/painting.pro index 2f98e8b..2f98e8b 100644 --- a/tests/benchmarks/declarative/painting/paintbenchmark.pro +++ b/tests/benchmarks/declarative/painting/painting.pro diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml index e48194a..b14531d 100644 --- a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import Qt.labs.particles 1.0 Item { id:block property bool dying: false diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp index acdc395..7bc6ca2 100644 --- a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp +++ b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp @@ -42,5 +42,5 @@ void registerTypes() { - QML_REGISTER_TYPE(Qt.test, 4, 6, MyQmlObject, MyQmlObject); + qmlRegisterType<MyQmlObject>("Qt.test", 4, 6, "MyQmlObject"); } diff --git a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp b/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp index a924337..20f0d93d 100644 --- a/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp +++ b/tests/benchmarks/declarative/qdeclarativetime/qdeclarativetime.cpp @@ -156,7 +156,7 @@ int main(int argc, char ** argv) { QApplication app(argc, argv); - QML_REGISTER_TYPE(QDeclarativeTime, 1, 0, Timer, Timer); + qmlRegisterType<Timer>("QDeclarativeTime", 1, 0, "Timer"); uint iterations = 1024; QString filename; diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp index 9dd4076..8ea6dcd 100644 --- a/tests/benchmarks/declarative/script/tst_script.cpp +++ b/tests/benchmarks/declarative/script/tst_script.cpp @@ -144,7 +144,7 @@ int TestObject::x() void tst_script::initTestCase() { - QML_REGISTER_TYPE(Qt.test, 1, 0, TestObject, TestObject); + qmlRegisterType<TestObject>("Qt.test", 1, 0, "TestObject"); } diff --git a/tests/benchmarks/gui/animation/qanimation/qanimation.pro b/tests/benchmarks/gui/animation/qanimation/qanimation.pro index 55cd75e..53a139a 100644 --- a/tests/benchmarks/gui/animation/qanimation/qanimation.pro +++ b/tests/benchmarks/gui/animation/qanimation/qanimation.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qanimation +TARGET = tst_bench_qanimation DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsanchorlayout/qgraphicsanchorlayout.pro b/tests/benchmarks/gui/graphicsview/qgraphicsanchorlayout/qgraphicsanchorlayout.pro index 0d563b9..3ede6e8 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsanchorlayout/qgraphicsanchorlayout.pro +++ b/tests/benchmarks/gui/graphicsview/qgraphicsanchorlayout/qgraphicsanchorlayout.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qgraphicsanchorlayout +TARGET = tst_bench_qgraphicsanchorlayout SOURCES += tst_qgraphicsanchorlayout.cpp diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsitem/qgraphicsitem.pro b/tests/benchmarks/gui/graphicsview/qgraphicsitem/qgraphicsitem.pro index 726bb96..d4935c0 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsitem/qgraphicsitem.pro +++ b/tests/benchmarks/gui/graphicsview/qgraphicsitem/qgraphicsitem.pro @@ -1,5 +1,5 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qgraphicsitem +TARGET = tst_bench_qgraphicsitem SOURCES += tst_qgraphicsitem.cpp diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsscene/qgraphicsscene.pro b/tests/benchmarks/gui/graphicsview/qgraphicsscene/qgraphicsscene.pro index b460e2a..1b7a5dc 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsscene/qgraphicsscene.pro +++ b/tests/benchmarks/gui/graphicsview/qgraphicsscene/qgraphicsscene.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qgraphicsscene +TARGET = tst_bench_qgraphicsscene SOURCES += tst_qgraphicsscene.cpp diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/qgraphicsview.pro b/tests/benchmarks/gui/graphicsview/qgraphicsview/qgraphicsview.pro index 927d731..6e044f9 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsview/qgraphicsview.pro +++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/qgraphicsview.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qgraphicsview +TARGET = tst_bench_qgraphicsview SOURCES += tst_qgraphicsview.cpp RESOURCES += qgraphicsview.qrc diff --git a/tests/benchmarks/gui/graphicsview/qgraphicswidget/qgraphicswidget.pro b/tests/benchmarks/gui/graphicsview/qgraphicswidget/qgraphicswidget.pro index f1ec54e..ed53237 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicswidget/qgraphicswidget.pro +++ b/tests/benchmarks/gui/graphicsview/qgraphicswidget/qgraphicswidget.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qgraphicswidget +TARGET = tst_bench_qgraphicswidget TEMPLATE = app # Input SOURCES += tst_qgraphicswidget.cpp diff --git a/tests/benchmarks/gui/image/blendbench/blendbench.pro b/tests/benchmarks/gui/image/blendbench/blendbench.pro index a3228c5..aa6ab95 100644 --- a/tests/benchmarks/gui/image/blendbench/blendbench.pro +++ b/tests/benchmarks/gui/image/blendbench/blendbench.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_blendbench +TARGET = tst_bench_blendbench DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/gui/image/qimagereader/qimagereader.pro b/tests/benchmarks/gui/image/qimagereader/qimagereader.pro index 276ac33..d67f4be 100644 --- a/tests/benchmarks/gui/image/qimagereader/qimagereader.pro +++ b/tests/benchmarks/gui/image/qimagereader/qimagereader.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qimagereader +TARGET = tst_bench_qimagereader SOURCES += tst_qimagereader.cpp diff --git a/tests/benchmarks/gui/image/qpixmap/qpixmap.pro b/tests/benchmarks/gui/image/qpixmap/qpixmap.pro index e8330bd..201ac9e 100644 --- a/tests/benchmarks/gui/image/qpixmap/qpixmap.pro +++ b/tests/benchmarks/gui/image/qpixmap/qpixmap.pro @@ -1,5 +1,5 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qpixmap +TARGET = tst_bench_qpixmap SOURCES += tst_qpixmap.cpp diff --git a/tests/benchmarks/gui/image/qpixmapcache/qpixmapcache.pro b/tests/benchmarks/gui/image/qpixmapcache/qpixmapcache.pro index e0d7543..78ac97d 100644 --- a/tests/benchmarks/gui/image/qpixmapcache/qpixmapcache.pro +++ b/tests/benchmarks/gui/image/qpixmapcache/qpixmapcache.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qpixmapcache +TARGET = tst_bench_qpixmapcache TEMPLATE = app # Input SOURCES += tst_qpixmapcache.cpp diff --git a/tests/benchmarks/gui/itemviews/qtableview/qtableview.pro b/tests/benchmarks/gui/itemviews/qtableview/qtableview.pro index 02bc530..3f4d4e1 100644 --- a/tests/benchmarks/gui/itemviews/qtableview/qtableview.pro +++ b/tests/benchmarks/gui/itemviews/qtableview/qtableview.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qtableview +TARGET = tst_bench_qtableview SOURCES += tst_qtableview.cpp diff --git a/tests/benchmarks/gui/kernel/qapplication/qapplication.pro b/tests/benchmarks/gui/kernel/qapplication/qapplication.pro index f8601e4..e12a60c 100644 --- a/tests/benchmarks/gui/kernel/qapplication/qapplication.pro +++ b/tests/benchmarks/gui/kernel/qapplication/qapplication.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qapplication +TARGET = tst_bench_qapplication DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/gui/kernel/qwidget/qwidget.pro b/tests/benchmarks/gui/kernel/qwidget/qwidget.pro index ff47445..4c6e5c7 100644 --- a/tests/benchmarks/gui/kernel/qwidget/qwidget.pro +++ b/tests/benchmarks/gui/kernel/qwidget/qwidget.pro @@ -1,4 +1,4 @@ load(qttest_p4) -TARGET = tst_qwidget +TARGET = tst_bench_qwidget SOURCES += tst_qwidget.cpp diff --git a/tests/benchmarks/gui/math3d/qmatrix4x4/qmatrix4x4.pro b/tests/benchmarks/gui/math3d/qmatrix4x4/qmatrix4x4.pro index e82d9de..b6a2046 100644 --- a/tests/benchmarks/gui/math3d/qmatrix4x4/qmatrix4x4.pro +++ b/tests/benchmarks/gui/math3d/qmatrix4x4/qmatrix4x4.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qmatrix4x4 +TARGET = tst_bench_qmatrix4x4 SOURCES += tst_qmatrix4x4.cpp diff --git a/tests/benchmarks/gui/math3d/qquaternion/qquaternion.pro b/tests/benchmarks/gui/math3d/qquaternion/qquaternion.pro index cd68423..bd6a0d3 100644 --- a/tests/benchmarks/gui/math3d/qquaternion/qquaternion.pro +++ b/tests/benchmarks/gui/math3d/qquaternion/qquaternion.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qquaternion +TARGET = tst_bench_qquaternion SOURCES += tst_qquaternion.cpp diff --git a/tests/benchmarks/gui/painting/qpainter/qpainter.pro b/tests/benchmarks/gui/painting/qpainter/qpainter.pro index 5ac8c64..6603aba 100644 --- a/tests/benchmarks/gui/painting/qpainter/qpainter.pro +++ b/tests/benchmarks/gui/painting/qpainter/qpainter.pro @@ -1,5 +1,5 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qpainter +TARGET = tst_bench_qpainter SOURCES += tst_qpainter.cpp diff --git a/tests/benchmarks/gui/painting/qregion/main.cpp b/tests/benchmarks/gui/painting/qregion/main.cpp index 3d16e41..1d19854 100644 --- a/tests/benchmarks/gui/painting/qregion/main.cpp +++ b/tests/benchmarks/gui/painting/qregion/main.cpp @@ -49,6 +49,9 @@ class tst_qregion : public QObject private slots: void map_data(); void map(); + + void intersects_data(); + void intersects(); }; @@ -84,6 +87,53 @@ void tst_qregion::map() } } +void tst_qregion::intersects_data() +{ + QTest::addColumn<QRegion>("region"); + QTest::addColumn<QRect>("rect"); + + QRegion region(0, 0, 100, 100); + QRegion complexRegion; + complexRegion = complexRegion.united(QRect(0, 0, 100, 100)); + complexRegion = complexRegion.united(QRect(120, 20, 100, 100)); + + { + QRect rect(0, 0, 100, 100); + QTest::newRow("same -- simple") << region << rect; + } + { + QRect rect(10, 10, 10, 10); + QTest::newRow("inside -- simple") << region << rect; + } + { + QRect rect(110, 110, 10, 10); + QTest::newRow("outside -- simple") << region << rect; + } + + { + QRect rect(0, 0, 100, 100); + QTest::newRow("same -- complex") << complexRegion << rect; + } + { + QRect rect(10, 10, 10, 10); + QTest::newRow("inside -- complex") << complexRegion << rect; + } + { + QRect rect(110, 110, 10, 10); + QTest::newRow("outside -- complex") << complexRegion << rect; + } +} + +void tst_qregion::intersects() +{ + QFETCH(QRegion, region); + QFETCH(QRect, rect); + + QBENCHMARK { + region.intersects(rect); + } +} + QTEST_MAIN(tst_qregion) #include "main.moc" diff --git a/tests/benchmarks/gui/painting/qregion/qregion.pro b/tests/benchmarks/gui/painting/qregion/qregion.pro index fc67177..ec93a62 100644 --- a/tests/benchmarks/gui/painting/qregion/qregion.pro +++ b/tests/benchmarks/gui/painting/qregion/qregion.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qregion +TARGET = tst_bench_qregion DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/gui/painting/qtransform/qtransform.pro b/tests/benchmarks/gui/painting/qtransform/qtransform.pro index 8d87656..dc60407 100644 --- a/tests/benchmarks/gui/painting/qtransform/qtransform.pro +++ b/tests/benchmarks/gui/painting/qtransform/qtransform.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qtransform +TARGET = tst_bench_qtransform SOURCES += tst_qtransform.cpp diff --git a/tests/benchmarks/gui/styles/qstylesheetstyle/qstylesheetstyle.pro b/tests/benchmarks/gui/styles/qstylesheetstyle/qstylesheetstyle.pro index c097307..f4bf9ab 100644 --- a/tests/benchmarks/gui/styles/qstylesheetstyle/qstylesheetstyle.pro +++ b/tests/benchmarks/gui/styles/qstylesheetstyle/qstylesheetstyle.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qstylesheetstyle +TARGET = tst_bench_qstylesheetstyle DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/gui/text/qfontmetrics/qfontmetrics.pro b/tests/benchmarks/gui/text/qfontmetrics/qfontmetrics.pro index b6c7b92..973f881 100644 --- a/tests/benchmarks/gui/text/qfontmetrics/qfontmetrics.pro +++ b/tests/benchmarks/gui/text/qfontmetrics/qfontmetrics.pro @@ -1,5 +1,5 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_QFontMetrics +TARGET = tst_bench_QFontMetrics SOURCES += main.cpp diff --git a/tests/benchmarks/gui/text/qtext/qtext.pro b/tests/benchmarks/gui/text/qtext/qtext.pro index 9e8860f..a1b6a22 100644 --- a/tests/benchmarks/gui/text/qtext/qtext.pro +++ b/tests/benchmarks/gui/text/qtext/qtext.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_QText +TARGET = tst_bench_QText SOURCES += main.cpp diff --git a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro index 89f5d31..0949af7 100644 --- a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro +++ b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/qfile_vs_qnetworkaccessmanager.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qfile_vs_qnetworkaccessmanager +TARGET = tst_bench_qfile_vs_qnetworkaccessmanager DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/network/access/qnetworkreply/qnetworkreply.pro b/tests/benchmarks/network/access/qnetworkreply/qnetworkreply.pro index 1e67d81..9d96dc7 100644 --- a/tests/benchmarks/network/access/qnetworkreply/qnetworkreply.pro +++ b/tests/benchmarks/network/access/qnetworkreply/qnetworkreply.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qnetworkreply +TARGET = tst_bench_qnetworkreply DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/network/kernel/qhostinfo/qhostinfo.pro b/tests/benchmarks/network/kernel/qhostinfo/qhostinfo.pro index f18d6d7..e621d50 100755 --- a/tests/benchmarks/network/kernel/qhostinfo/qhostinfo.pro +++ b/tests/benchmarks/network/kernel/qhostinfo/qhostinfo.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qhostinfo +TARGET = tst_bench_qhostinfo DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/network/socket/qtcpserver/qtcpserver.pro b/tests/benchmarks/network/socket/qtcpserver/qtcpserver.pro index e7bf13a..e5b9346 100644 --- a/tests/benchmarks/network/socket/qtcpserver/qtcpserver.pro +++ b/tests/benchmarks/network/socket/qtcpserver/qtcpserver.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qtcpserver +TARGET = tst_bench_qtcpserver DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/opengl/opengl.pro b/tests/benchmarks/opengl/opengl.pro index 1458b5e..5c58751 100644 --- a/tests/benchmarks/opengl/opengl.pro +++ b/tests/benchmarks/opengl/opengl.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_opengl +TARGET = tst_bench_opengl DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/benchmarks/plugins/imageformats/jpeg/jpeg.cpp b/tests/benchmarks/plugins/imageformats/jpeg/jpeg.cpp new file mode 100644 index 0000000..2cb9421 --- /dev/null +++ b/tests/benchmarks/plugins/imageformats/jpeg/jpeg.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QDebug> +#include <qtest.h> +#include <QtTest/QtTest> +#include <QFile> +#include <QByteArray> +#include <QBuffer> +#include <QImageReader> +#include <QSize> + +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif + +class tst_jpeg : public QObject +{ + Q_OBJECT +private slots: + void jpegDecodingQtWebkitStyle(); +}; + +void tst_jpeg::jpegDecodingQtWebkitStyle() +{ + // QtWebkit currently calls size() to get the image size for layouting purposes. + // Then when it is in the viewport (we assume that here) it actually gets decoded. + QFile inputJpeg(SRCDIR "n900.jpeg"); + QVERIFY(inputJpeg.exists()); + inputJpeg.open(QIODevice::ReadOnly); + QByteArray imageData = inputJpeg.readAll(); + QBuffer buffer; + buffer.setData(imageData); + buffer.open(QBuffer::ReadOnly); + QCOMPARE(buffer.size(), qint64(19016)); + + + QBENCHMARK{ + for (int i = 0; i < 50; i++) { + QImageReader reader(&buffer, "jpeg"); + QSize size = reader.size(); + QVERIFY(!size.isNull()); + QByteArray format = reader.format(); + QVERIFY(!format.isEmpty()); + QImage img = reader.read(); + QVERIFY(!img.isNull()); + buffer.reset(); + } + } +} + +QTEST_MAIN(tst_jpeg) + +#include "jpeg.moc" diff --git a/tests/benchmarks/plugins/imageformats/jpeg/jpeg.pro b/tests/benchmarks/plugins/imageformats/jpeg/jpeg.pro new file mode 100644 index 0000000..e106f3e --- /dev/null +++ b/tests/benchmarks/plugins/imageformats/jpeg/jpeg.pro @@ -0,0 +1,18 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = jpeg +DEPENDPATH += . +INCLUDEPATH += . + +CONFIG += release + +wince*: { + DEFINES += SRCDIR=\\\"\\\" +} else:symbian { + # SRCDIR and SVGFILE defined in code in symbian +}else { + DEFINES += SRCDIR=\\\"$$PWD/\\\" +} + +# Input +SOURCES += jpeg.cpp diff --git a/tests/benchmarks/plugins/imageformats/jpeg/n900.jpeg b/tests/benchmarks/plugins/imageformats/jpeg/n900.jpeg Binary files differnew file mode 100644 index 0000000..681989a --- /dev/null +++ b/tests/benchmarks/plugins/imageformats/jpeg/n900.jpeg diff --git a/tests/benchmarks/script/qscriptclass/qscriptclass.pro b/tests/benchmarks/script/qscriptclass/qscriptclass.pro index f0ffeb7..90c9582 100644 --- a/tests/benchmarks/script/qscriptclass/qscriptclass.pro +++ b/tests/benchmarks/script/qscriptclass/qscriptclass.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qscriptclass +TARGET = tst_bench_qscriptclass SOURCES += tst_qscriptclass.cpp diff --git a/tests/benchmarks/script/qscriptengine/qscriptengine.pro b/tests/benchmarks/script/qscriptengine/qscriptengine.pro index df6dbb3..72a547a 100644 --- a/tests/benchmarks/script/qscriptengine/qscriptengine.pro +++ b/tests/benchmarks/script/qscriptengine/qscriptengine.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qscriptengine +TARGET = tst_bench_qscriptengine SOURCES += tst_qscriptengine.cpp diff --git a/tests/benchmarks/script/qscriptvalue/qscriptvalue.pro b/tests/benchmarks/script/qscriptvalue/qscriptvalue.pro index 04ea324..1c26438 100644 --- a/tests/benchmarks/script/qscriptvalue/qscriptvalue.pro +++ b/tests/benchmarks/script/qscriptvalue/qscriptvalue.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qscriptvalue +TARGET = tst_bench_qscriptvalue SOURCES += tst_qscriptvalue.cpp diff --git a/tests/benchmarks/script/qscriptvalueiterator/qscriptvalueiterator.pro b/tests/benchmarks/script/qscriptvalueiterator/qscriptvalueiterator.pro new file mode 100644 index 0000000..ecd48f0 --- /dev/null +++ b/tests/benchmarks/script/qscriptvalueiterator/qscriptvalueiterator.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qscriptvalueiterator + +SOURCES += tst_qscriptvalueiterator.cpp + +QT = core script diff --git a/tests/benchmarks/script/qscriptvalueiterator/tst_qscriptvalueiterator.cpp b/tests/benchmarks/script/qscriptvalueiterator/tst_qscriptvalueiterator.cpp new file mode 100644 index 0000000..7d06744 --- /dev/null +++ b/tests/benchmarks/script/qscriptvalueiterator/tst_qscriptvalueiterator.cpp @@ -0,0 +1,293 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 <qtest.h> +#include <QtScript> + +//TESTED_FILES= + +class tst_QScriptValueIterator : public QObject +{ + Q_OBJECT + +public: + tst_QScriptValueIterator(); + virtual ~tst_QScriptValueIterator(); + + void dataHelper(); + +private slots: + void init(); + void cleanup(); + + void hasNextAndNext(); + + void constructAndNext_data(); + void constructAndNext(); + + void name_data(); + void name(); + void scriptName_data(); + void scriptName(); + + void value_data(); + void value(); + void setValue_data(); + void setValue(); + + void flags(); + + void iterateArrayAndConvertNameToIndex(); + void iterateArrayAndDoubleElements(); + void iterateArrayAndRemoveAllElements(); +}; + +tst_QScriptValueIterator::tst_QScriptValueIterator() +{ +} + +tst_QScriptValueIterator::~tst_QScriptValueIterator() +{ +} + +void tst_QScriptValueIterator::init() +{ +} + +void tst_QScriptValueIterator::cleanup() +{ +} + +void tst_QScriptValueIterator::dataHelper() +{ + QTest::addColumn<QString>("code"); + QTest::newRow("{ foo: 123 }") << QString::fromLatin1("({ foo: 123 })"); + QTest::newRow("Math") << QString::fromLatin1("Math"); + QTest::newRow("Array.prototype") << QString::fromLatin1("Array.prototype"); + QTest::newRow("Global Object") << QString::fromLatin1("this"); + QTest::newRow("['foo']") << QString::fromLatin1("['foo']"); + QTest::newRow("array with 1000 elements") + << QString::fromLatin1("(function() {" + " var a = new Array;" + " for (i = 0; i < 1000; ++i)" + " a[i] = i;" + " return a;" + "})()"); +} + +void tst_QScriptValueIterator::hasNextAndNext() +{ + QScriptEngine engine; + QScriptValue object = engine.newObject(); + for (int i = 0; i < 2000; ++i) + object.setProperty(i, i); + QScriptValueIterator it(object); + QBENCHMARK { + for (int i = 0; i < 1000; ++i) { + it.toFront(); + while (it.hasNext()) + it.next(); + } + } +} + +void tst_QScriptValueIterator::constructAndNext_data() +{ + dataHelper(); +} + +void tst_QScriptValueIterator::constructAndNext() +{ + QFETCH(QString, code); + QScriptEngine engine; + QScriptValue object = engine.evaluate(code); + Q_ASSERT(object.isObject()); + + QBENCHMARK { + for (int i = 0; i < 100; ++i) { + QScriptValueIterator it(object); + it.next(); + } + } +} + +void tst_QScriptValueIterator::name_data() +{ + dataHelper(); +} + +void tst_QScriptValueIterator::name() +{ + QFETCH(QString, code); + QScriptEngine engine; + QScriptValue object = engine.evaluate(code); + Q_ASSERT(object.isObject()); + + QScriptValueIterator it(object); + it.next(); + QBENCHMARK { + for (int i = 0; i < 200000; ++i) + it.name(); + } +} + +void tst_QScriptValueIterator::scriptName_data() +{ + dataHelper(); +} + +void tst_QScriptValueIterator::scriptName() +{ + QFETCH(QString, code); + QScriptEngine engine; + QScriptValue object = engine.evaluate(code); + Q_ASSERT(object.isObject()); + + QScriptValueIterator it(object); + it.next(); + QBENCHMARK { + for (int i = 0; i < 50000; ++i) + it.scriptName(); + } +} + +void tst_QScriptValueIterator::value_data() +{ + dataHelper(); +} + +void tst_QScriptValueIterator::value() +{ + QFETCH(QString, code); + QScriptEngine engine; + QScriptValue object = engine.evaluate(code); + Q_ASSERT(object.isObject()); + + QScriptValueIterator it(object); + it.next(); + QBENCHMARK { + for (int i = 0; i < 50000; ++i) + it.value(); + } +} + +void tst_QScriptValueIterator::setValue_data() +{ + dataHelper(); +} + +void tst_QScriptValueIterator::setValue() +{ + QFETCH(QString, code); + QScriptEngine engine; + QScriptValue object = engine.evaluate(code); + Q_ASSERT(object.isObject()); + + QScriptValueIterator it(object); + it.next(); + QScriptValue newValue(&engine, 456); + QBENCHMARK { + for (int i = 0; i < 50000; ++i) + it.setValue(newValue); + } +} + +void tst_QScriptValueIterator::flags() +{ + QScriptEngine engine; + QScriptValue object = engine.newObject(); + QScriptValue::PropertyFlags flags = flags; + object.setProperty("foo", 123, QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly | QScriptValue::Undeletable); + QScriptValueIterator it(object); + it.next(); + QBENCHMARK { + for (int i = 0; i < 50000; ++i) + it.flags(); + } +} + +void tst_QScriptValueIterator::iterateArrayAndConvertNameToIndex() +{ + QScriptEngine engine; + QScriptValue array = engine.newArray(); + for (int i = 0; i < 20000; ++i) + array.setProperty(i, i); + QBENCHMARK { + QScriptValueIterator it(array); + while (it.hasNext()) { + it.next(); + it.scriptName().toArrayIndex(); + } + } +} + +void tst_QScriptValueIterator::iterateArrayAndDoubleElements() +{ + QScriptEngine engine; + QScriptValue array = engine.newArray(); + for (int i = 0; i < 20000; ++i) + array.setProperty(i, i); + QBENCHMARK { + QScriptValueIterator it(array); + while (it.hasNext()) { + it.next(); + it.setValue(QScriptValue(&engine, it.value().toNumber() * 2)); + } + } +} + +void tst_QScriptValueIterator::iterateArrayAndRemoveAllElements() +{ + QScriptEngine engine; + QScriptValue array = engine.newArray(); + for (int i = 0; i < 20000; ++i) + array.setProperty(i, i); + QBENCHMARK { + QScriptValueIterator it(array); + while (it.hasNext()) { + it.next(); + it.remove(); + } + } +} + +QTEST_MAIN(tst_QScriptValueIterator) +#include "tst_qscriptvalueiterator.moc" diff --git a/tests/benchmarks/svg/qsvgrenderer/qsvgrenderer.pro b/tests/benchmarks/svg/qsvgrenderer/qsvgrenderer.pro index 8222a09..9e59eb7 100644 --- a/tests/benchmarks/svg/qsvgrenderer/qsvgrenderer.pro +++ b/tests/benchmarks/svg/qsvgrenderer/qsvgrenderer.pro @@ -1,6 +1,6 @@ load(qttest_p4) TEMPLATE = app -TARGET = tst_qsvgrenderer +TARGET = tst_bench_qsvgrenderer SOURCES += tst_qsvgrenderer.cpp RESOURCES += qsvgrenderer.qrc diff --git a/tests/manual/networkmanager/README b/tests/manual/networkmanager/README deleted file mode 100644 index 4bc7171..0000000 --- a/tests/manual/networkmanager/README +++ /dev/null @@ -1,2 +0,0 @@ -This application serves as prototype/test-bed for NetworkManager development. The excellent (non-existing) documentation -for the various NetworkManager interfaces makes this harder than it should be. diff --git a/tests/manual/networkmanager/dialog.ui b/tests/manual/networkmanager/dialog.ui deleted file mode 100644 index 1301908..0000000 --- a/tests/manual/networkmanager/dialog.ui +++ /dev/null @@ -1,213 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Dialog</class> - <widget class="QDialog" name="Dialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>919</width> - <height>657</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Connections</string> - </property> - </widget> - </item> - <item> - <widget class="QTreeWidget" name="cons"> - <column> - <property name="text"> - <string>Path</string> - </property> - </column> - <column> - <property name="text"> - <string>State</string> - </property> - </column> - <column> - <property name="text"> - <string>Id</string> - </property> - </column> - <column> - <property name="text"> - <string>Settings</string> - </property> - </column> - </widget> - </item> - </layout> - </item> - <item row="1" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Devices:</string> - </property> - </widget> - </item> - <item> - <widget class="QTreeWidget" name="devicesTreeWidget"> - <column> - <property name="text"> - <string>Path</string> - </property> - </column> - <column> - <property name="text"> - <string>Managed</string> - </property> - </column> - <column> - <property name="text"> - <string>Interface</string> - </property> - </column> - <column> - <property name="text"> - <string>Driver</string> - </property> - </column> - <column> - <property name="text"> - <string>Type</string> - </property> - </column> - <column> - <property name="text"> - <string>State</string> - </property> - </column> - <column> - <property name="text"> - <string>IP4 Address</string> - </property> - </column> - <column> - <property name="text"> - <string>IP4 Config</string> - </property> - </column> - <column> - <property name="text"> - <string>Hostname</string> - </property> - </column> - <column> - <property name="text"> - <string>Domains</string> - </property> - </column> - </widget> - </item> - </layout> - </item> - <item row="2" column="0"> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>908</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="3" column="0"> - <widget class="QTreeWidget" name="accessPointsTreeWidget"> - <property name="sortingEnabled"> - <bool>true</bool> - </property> - <column> - <property name="text"> - <string>SSID</string> - </property> - </column> - <column> - <property name="text"> - <string>Strength</string> - </property> - </column> - <column> - <property name="text"> - <string>Wpa</string> - </property> - </column> - <column> - <property name="text"> - <string>Rsn</string> - </property> - </column> - <column> - <property name="text"> - <string>Freq</string> - </property> - </column> - <column> - <property name="text"> - <string>Hardware Address</string> - </property> - </column> - <column> - <property name="text"> - <string>Mode</string> - </property> - </column> - <column> - <property name="text"> - <string>Max Bitrate</string> - </property> - </column> - </widget> - </item> - <item row="4" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QPushButton" name="startButton"> - <property name="text"> - <string>Start</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="stopButton"> - <property name="text"> - <string>Stop</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="scanButton"> - <property name="text"> - <string>Scan</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="updateButton"> - <property name="text"> - <string>Update</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/tests/manual/networkmanager/networkmanager.pro b/tests/manual/networkmanager/networkmanager.pro deleted file mode 100644 index 84289d3..0000000 --- a/tests/manual/networkmanager/networkmanager.pro +++ /dev/null @@ -1,9 +0,0 @@ -SOURCES += networkmanagertest.cpp nmview.cpp -HEADERS += nmview.h -TARGET = tst_networkmanagertest - -QT = core network dbus gui - -requires(contains(QT_CONFIG,dbus)) - -FORMS += dialog.ui diff --git a/tests/manual/networkmanager/networkmanagertest.cpp b/tests/manual/networkmanager/networkmanagertest.cpp deleted file mode 100644 index 8a6c5fa..0000000 --- a/tests/manual/networkmanager/networkmanagertest.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QDBusConnection> -#include <QDBusError> -#include <QDBusInterface> -#include <QDBusMessage> -#include <QDBusReply> -#include <QtDBus> -#include <QHostAddress> -#include <QDebug> -#include <NetworkManager/NetworkManager.h> -#include <QApplication> -#include <QMainWindow> -#include "nmview.h" - -#include <arpa/inet.h> - -typedef QMap< QString, QMap<QString,QVariant> > SettingsMap; -Q_DECLARE_METATYPE(SettingsMap) - -void printConnectionDetails(const QString& service) -{ - QDBusConnection dbc = QDBusConnection::systemBus(); - if (!dbc.isConnected()) { - qWarning() << "Unable to connect to D-Bus:" << dbc.lastError(); - return; - } - QDBusInterface allCons(service, NM_DBUS_PATH_SETTINGS, NM_DBUS_IFACE_SETTINGS, dbc); - if (allCons.isValid()) { - QDBusReply<QList<QDBusObjectPath> > reply = allCons.call("ListConnections"); - if ( reply.isValid() ) { - qWarning() << "Known connections:"; - QList<QDBusObjectPath> list = reply.value(); - foreach(QDBusObjectPath path, list) { - qWarning() << " " << path.path(); - QDBusInterface sysIface(NM_DBUS_SERVICE_SYSTEM_SETTINGS, path.path(), NM_DBUS_IFACE_SETTINGS_CONNECTION, dbc); - if (sysIface.isValid()) { - QDBusMessage r = sysIface.call("GetSettings"); - QDBusReply< SettingsMap > rep = sysIface.call("GetSettings"); - qWarning() << " GetSettings:" << r.arguments() << r.signature() << rep.isValid() << sysIface.lastError(); - QMap< QString, QMap<QString,QVariant> > map = rep.value(); - QList<QString> list = map.keys(); - foreach (QString key, list) { - QMap<QString,QVariant> innerMap = map[key]; - qWarning() << " Key: " << key; - QMap<QString,QVariant>::const_iterator i = innerMap.constBegin(); - while (i != innerMap.constEnd()) { - QString k = i.key(); - qWarning() << " Key: " << k << " Entry: " << i.value(); - if (k == "addresses" && i.value().canConvert<QDBusArgument>()) { - QDBusArgument arg = i.value().value<QDBusArgument>(); - arg.beginArray(); - while (!arg.atEnd()) { - QDBusVariant addr; - arg >> addr; - uint ip = addr.variant().toUInt(); - qWarning() << ip; - qWarning() << " " << QHostAddress(htonl(ip)).toString(); - } - - } - i++; - } - } - } - } - } - } - - -} - -void readConnectionManagerDetails() -{ - qDBusRegisterMetaType<SettingsMap>(); - QDBusConnection dbc = QDBusConnection::systemBus(); - if (!dbc.isConnected()) { - qWarning() << "Unable to connect to D-Bus:" << dbc.lastError(); - return; - } - - QDBusInterface iface(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, dbc); - if (!iface.isValid()) { - qWarning() << "Could not find NetworkManager"; - return; - } - - uint state = iface.property("State").toUInt(); - switch(state) { - case NM_STATE_UNKNOWN: - qWarning() << "State: Unknown"; break; - case NM_STATE_ASLEEP: - qWarning() << "State: Asleep"; break; - case NM_STATE_CONNECTING: - qWarning() << "State: Connecting"; break; - case NM_STATE_CONNECTED: - qWarning() << "State: Connected"; break; - case NM_STATE_DISCONNECTED: - qWarning() << "State: Disconnected"; break; - } - //get list of network devices - QDBusReply<QList<QDBusObjectPath> > reply = iface.call("GetDevices"); - if ( reply.isValid() ) { - qWarning() << "Current devices:"; - QList<QDBusObjectPath> list = reply.value(); - foreach(QDBusObjectPath path, list) { - qWarning() << " " << path.path(); - QDBusInterface devIface(NM_DBUS_SERVICE, path.path(), NM_DBUS_INTERFACE_DEVICE, dbc); - if (devIface.isValid()) { - qWarning() << " Managed: " << devIface.property("Managed").toBool(); - qWarning() << " Interface: " << devIface.property("Interface").toString(); - qWarning() << " HAL UDI: " << devIface.property("Udi").toString(); - qWarning() << " Driver: " << devIface.property("Driver").toString(); - QVariant v = devIface.property("DeviceType"); - switch(v.toUInt()) { - case DEVICE_TYPE_UNKNOWN: - qWarning() << " DeviceType: Unknown" ; - break; - case DEVICE_TYPE_802_3_ETHERNET: - qWarning() << " DeviceType: Ethernet" ; - break; - case DEVICE_TYPE_802_11_WIRELESS: - qWarning() << " DeviceType: Wireless" ; - break; - case DEVICE_TYPE_GSM: - qWarning() << " DeviceType: GSM" ; - break; - case DEVICE_TYPE_CDMA: - qWarning() << " DeviceType: CDMA" ; - break; - - } - v = devIface.property("State"); - switch(v.toUInt()) { - case NM_DEVICE_STATE_UNKNOWN: - qWarning() << " State: Unknown" ; break; - case NM_DEVICE_STATE_UNMANAGED: - qWarning() << " State: Unmanaged" ; break; - case NM_DEVICE_STATE_UNAVAILABLE: - qWarning() << " State: Unavailable" ; break; - case NM_DEVICE_STATE_DISCONNECTED: - qWarning() << " State: Disconnected" ; break; - case NM_DEVICE_STATE_PREPARE: - qWarning() << " State: Preparing" ; break; - case NM_DEVICE_STATE_CONFIG: - qWarning() << " State: Being configured" ; break; - case NM_DEVICE_STATE_NEED_AUTH: - qWarning() << " State: Awaiting secrets" ; break; - case NM_DEVICE_STATE_IP_CONFIG: - qWarning() << " State: IP requested" ; break; - case NM_DEVICE_STATE_ACTIVATED: - qWarning() << " State: Activated" ; break; - case NM_DEVICE_STATE_FAILED: - qWarning() << " State: FAILED" ; break; - } - quint32 ip = devIface.property("Ip4Address").toUInt(); - qWarning() << " IP4Address: " << QHostAddress(htonl(ip)).toString(); - if (v.toUInt() == NM_DEVICE_STATE_ACTIVATED) { - QString path = devIface.property("Ip4Config").value<QDBusObjectPath>().path(); - qWarning() << " IP4Config: " << path; - QDBusInterface ipIface(NM_DBUS_SERVICE, path, NM_DBUS_INTERFACE_IP4_CONFIG, dbc); - if (ipIface.isValid()) { - qWarning() << " Hostname: " << ipIface.property("Hostname").toString(); - qWarning() << " Domains: " << ipIface.property("Domains").toStringList(); - qWarning() << " NisDomain: " << ipIface.property("NisDomain").toString(); - QDBusArgument arg= ipIface.property("Addresses").value<QDBusArgument>(); - //qWarning() << " " << arg.currentType(); - qWarning() << " Addresses: " << ipIface.property("Addresses"); - qWarning() << " Nameservers: " << ipIface.property("Nameservers"); - qWarning() << " NisServers: " << ipIface.property("NisServers"); - } - - } - - } - } - } - - //get list of active connections - QVariant prop = iface.property("ActiveConnections"); - QList<QDBusObjectPath> connections = prop.value<QList<QDBusObjectPath> >(); - QString activePath; - if ( connections.count() ) - qWarning() << "Active connections:"; - foreach(QDBusObjectPath path, connections) { - qWarning() << " " << path.path(); - activePath = path.path(); - QString serviceName; - QDBusInterface conIface(NM_DBUS_SERVICE, path.path(), NM_DBUS_INTERFACE_ACTIVE_CONNECTION, dbc); - if (conIface.isValid()) { - qWarning() << " default connection: " << conIface.property("Default").toBool(); - serviceName = conIface.property("ServiceName").toString(); - qWarning() << " service name: " << serviceName; - qWarning() << " connection path: " << conIface.property("Connection").value<QDBusObjectPath>().path(); - qWarning() << " specific object:" << conIface.property("SpecificObject").value<QDBusObjectPath>().path(); - qWarning() << " sharedServiceName: " << conIface.property("SharedServiceName").toString(); - QList<QDBusObjectPath> devs = conIface.property("Devices").value<QList<QDBusObjectPath> >(); - qWarning() << " devices: "; - foreach(QDBusObjectPath p, devs) - qWarning() << " " << path.path(); - QVariant v = conIface.property("State"); - switch (v.toInt()) { - case NM_ACTIVE_CONNECTION_STATE_UNKNOWN: - qWarning()<< " State: unknown"; break; - case NM_ACTIVE_CONNECTION_STATE_ACTIVATING: - qWarning()<< " State: activating"; break; - case NM_ACTIVE_CONNECTION_STATE_ACTIVATED: - qWarning()<< " State: activated"; break; - } - } else { - qWarning() << conIface.lastError(); - } - - } - - printConnectionDetails(NM_DBUS_SERVICE_SYSTEM_SETTINGS); - printConnectionDetails(NM_DBUS_SERVICE_USER_SETTINGS); - - - //turn active connection off - /*QDBusObjectPath dbop("/org/freedesktop/NetworkManager/ActiveConnection/1"); - QVariant asd = QVariant::fromValue(dbop); - iface.call(QLatin1String("DeactivateConnection"), asd); - qWarning() << iface.lastError();*/ - - /*QDBusObjectPath p1device("/org/freedesktop/Hal/devices/net_00_60_6e_82_02_65"); - QVariant p1v = QVariant::fromValue(p1device); - QDBusObjectPath p1con("/org/freedesktop/NetworkManagerSettings/0"); - QVariant p1c = QVariant::fromValue(p1con); - QDBusObjectPath p1sp(""); - QVariant p1sp1 = QVariant::fromValue(p1sp); - iface.call(QLatin1String("ActivateConnection"), - QString("/org/freedesktop/NetworkManagerSystemSettings"), p1c,p1v, p1v ); - qWarning() << iface.lastError(); - */ -} - -int main( int argc, char** argv) -{ - QApplication app(argc, argv); - //readConnectionManagerDetails(); - QMainWindow main; - NMView view; - main.setCentralWidget(&view); - main.show(); - return app.exec(); - -} diff --git a/tests/manual/networkmanager/nmview.cpp b/tests/manual/networkmanager/nmview.cpp deleted file mode 100644 index 9e28ff0..0000000 --- a/tests/manual/networkmanager/nmview.cpp +++ /dev/null @@ -1,1028 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "nmview.h" - -#include <QLabel> -#include <QLayout> -#include <QListWidget> -#include <QDebug> -#include <QPushButton> - -#include <QtDBus> -#include <QtNetwork> -#include <NetworkManager/NetworkManager.h> -#include <arpa/inet.h> - -#include <QDBusConnection> -#include <QDBusError> -#include <QDBusInterface> -#include <QDBusMessage> -#include <QDBusReply> - -#include <QHostAddress> -#include <QNetworkInterface> -#include <QTreeWidgetItem> -#include <QMessageBox> - -//#include "ui_dialog.h" - -#include <qnetworkconfiguration.h> -#include <qnetworkconfigmanager.h> -#include <qnetworksession.h> -#include <QtNetwork/private/qnetworkmanagerservice_p.h> - -//static QDBusConnection dbc = QDBusConnection::systemBus(); -//typedef QMap< QString, QMap<QString,QVariant> > SettingsMap; -//Q_DECLARE_METATYPE(SettingsMap) - - -NMView::NMView(QDialog* parent) - : QDialog(parent, 0), dbc(QDBusConnection::systemBus()) -{ - init(); - - if (!dbc.isConnected()) { - qWarning() << "Unable to connect to D-Bus:" << dbc.lastError(); - return; - } - updateConnections(); - getDevices(); -} - -NMView::~NMView() -{ -} -void NMView::init() -{ - setupUi(this); - sess = 0; -// readSettings(); - connect(startButton, SIGNAL(clicked()), this, SLOT(activate())); - connect(stopButton, SIGNAL(clicked()), this, SLOT(deactivate())); - connect(scanButton, SIGNAL(clicked()), this, SLOT(findAccessPoints())); - connect(updateButton, SIGNAL(clicked()), this, SLOT(update())); - - connect(cons, SIGNAL(itemActivated(QTreeWidgetItem*, int)), - this,SLOT(connectionItemActivated(QTreeWidgetItem*, int))); - - - connect(devicesTreeWidget, SIGNAL(itemActivated(QTreeWidgetItem*, int)), - this, SLOT(deviceItemActivated(QTreeWidgetItem*, int))); - - cons->header()->setResizeMode(QHeaderView::ResizeToContents); - devicesTreeWidget->header()->setResizeMode(QHeaderView::ResizeToContents); - accessPointsTreeWidget->header()->setResizeMode(QHeaderView::ResizeToContents); -// accessPointsTreeWidget->header()->setResizeMode(QHeaderView::ResizeToContents); - - manager = new QNetworkConfigurationManager(this); - - connect(manager, SIGNAL(updateCompleted()), this, SLOT(updateCompleted())); - - connect(manager, SIGNAL(configurationAdded(const QNetworkConfiguration &)), - this, SLOT(configurationAdded(const QNetworkConfiguration&))); - - devicesTreeWidget->header()->hideSection(0); - devicesTreeWidget->header()->hideSection(1); - devicesTreeWidget->header()->hideSection(3); - devicesTreeWidget->header()->hideSection(5); - devicesTreeWidget->header()->hideSection(6); - devicesTreeWidget->header()->hideSection(7); - devicesTreeWidget->header()->hideSection(8); - devicesTreeWidget->header()->hideSection(9); -} - -void NMView::updateConnections() -{ - cons->clear(); - manager->updateConfigurations(); - QList<QNetworkConfiguration> configs = manager->allConfigurations(); - foreach(QNetworkConfiguration p, configs) { - QStringList strlist; - strlist << p.name(); - strlist << stateToString(p.state()); - strlist << p.identifier(); - strlist << typeToString(p.type()); - QTreeWidgetItem *item; - item = new QTreeWidgetItem(strlist); - cons->insertTopLevelItem(0, item); - } - cons->sortItems ( 1, Qt::AscendingOrder); -} - -void NMView::getActiveConnections() -{ - QList<QNetworkConfiguration> configs = manager->allConfigurations(QNetworkConfiguration::Active); - foreach(QNetworkConfiguration p, configs) { - qWarning() << __FUNCTION__ << p.name() << p.identifier(); - } - -// QDBusInterface iface(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, dbc); -// if (!iface.isValid()) { -// qWarning() << "Could not find NetworkManager"; -// return; -// } - -// QVariant prop = iface.property("ActiveConnections"); -// QList<QDBusObjectPath> connections = prop.value<QList<QDBusObjectPath> >(); -// foreach(QDBusObjectPath path, connections) { -// QDBusInterface conDetails(NM_DBUS_SERVICE, path.path(), NM_DBUS_INTERFACE_ACTIVE_CONNECTION, dbc); -// if (conDetails.isValid()) { -// QString desc = path.path(); -// conDetails.property("Connection Path").value<QDBusObjectPath>().path(); - -// QList<QDBusObjectPath> devices = conDetails.property("Devices").value<QList<QDBusObjectPath> >(); -// -// foreach(QDBusObjectPath devpath, devices) { -// QDBusInterface devIface(NM_DBUS_SERVICE, devpath.path(), NM_DBUS_INTERFACE_DEVICE, dbc); -// desc += " "+devIface.property("Interface").toString(); -// desc += " "+QHostAddress(htonl(devIface.property("Ip4Address").toUInt())).toString(); - -// } - -// qWarning() << conDetails.property("Connection").value<QDBusObjectPath>().path() << path.path(); - -// QListWidgetItem* item = new QListWidgetItem(desc, activeCons); -// item->setData(Qt::UserRole, path.path()); -// } -// } -} - -void NMView::update() -{ -// QNetworkManagerInterface *dbIface; -// dbIface = new QNetworkManagerInterface; -// QList <QDBusObjectPath> connections = dbIface->activeConnections(); -// -// foreach(QDBusObjectPath conpath, connections) { -// QNetworkManagerConnectionActive *aConn; -// aConn = new QNetworkManagerConnectionActive(conpath.path()); -// // in case of accesspoint, specificObject will hold the accessPOintObjectPath -// qWarning() << aConn->connection().path() << aConn->specificObject().path() << aConn->devices().count(); -// QList <QDBusObjectPath> devs = aConn->devices(); -// foreach(QDBusObjectPath device, devs) { -// qWarning() << " " << device.path(); -// } -// } - - QStringList connectionServices; - connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS; - connectionServices << NM_DBUS_SERVICE_USER_SETTINGS; - foreach (QString service, connectionServices) { - QDBusInterface allCons(service, - NM_DBUS_PATH_SETTINGS, - NM_DBUS_IFACE_SETTINGS, - dbc); - if (allCons.isValid()) { - QDBusReply<QList<QDBusObjectPath> > reply = allCons.call("ListConnections"); - if ( reply.isValid() ) { - QList<QDBusObjectPath> list = reply.value(); - foreach(QDBusObjectPath path, list) { - QDBusInterface sysIface(service, - path.path(), - NM_DBUS_IFACE_SETTINGS_CONNECTION, - dbc); - if (sysIface.isValid()) { - qWarning() << ""; - qWarning() << path.path(); - - // QDBusMessage r = sysIface.call("GetSettings"); - QDBusReply< QNmSettingsMap > rep = sysIface.call("GetSettings"); - - QMap< QString, QMap<QString,QVariant> > map = rep.value(); - QList<QString> list = map.keys(); - foreach (QString key, list) { - QMap<QString,QVariant> innerMap = map[key]; - qWarning() << " Key: " << key; - QMap<QString,QVariant>::const_iterator i = innerMap.constBegin(); - - while (i != innerMap.constEnd()) { - QString k = i.key(); - qWarning() << " Key: " << k << " Entry: " << i.value(); - i++; - }//end innerMap - }//end foreach key - }//end settings connection - } // foreach path - } //end ListConnections - } //end settingsInterface - }// end services - QDBusInterface iface(NM_DBUS_SERVICE, - NM_DBUS_PATH, - NM_DBUS_INTERFACE, - dbc); - if (iface.isValid()) { - QVariant prop = iface.property("ActiveConnections"); - QList<QDBusObjectPath> connections = prop.value<QList<QDBusObjectPath> >(); - foreach(QDBusObjectPath conpath, connections) { - qWarning() << "Active connection" << conpath.path(); - QDBusInterface conDetails(NM_DBUS_SERVICE, - conpath.path(), - NM_DBUS_INTERFACE_ACTIVE_CONNECTION, - dbc); - if (conDetails.isValid()) { - - QVariant prop = conDetails.property("Connection"); - QDBusObjectPath connection = prop.value<QDBusObjectPath>(); - qWarning() << conDetails.property("Default").toBool() << connection.path(); - -// QVariant Sprop = conDetails.property("Devices"); -// QList<QDBusObjectPath> so = Sprop.value<QList<QDBusObjectPath> >(); -// foreach(QDBusObjectPath device, so) { -// if(device.path() == devicePath) { -// path = connection.path(); -// } -// break; -// } - } - } - } -qWarning() << ""; -} - -void NMView::deactivate() -{ - QList<QNetworkConfiguration> configs = manager->allConfigurations(QNetworkConfiguration::Active); - foreach(QNetworkConfiguration p, configs) { - qWarning() << "Active cons" << p.name(); - if(p.name() == cons->currentItem()->text(0) - && p.identifier() == cons->currentItem()->text(2)) { - qWarning() <<__FUNCTION__<< p.name(); - if(!sess) { - sess = new QNetworkSession(p); - - connect(sess, SIGNAL(stateChanged(QNetworkSession::State)), - this, SLOT(stateChanged(QNetworkSession::State))); - - connect(sess, SIGNAL(error(QNetworkSession::SessionError)), - this, SLOT(networkSessionError(QNetworkSession::SessionError))); - } - sess->close(); - delete sess; - sess = 0; - } - } -} - -void NMView::activate() -{ - qWarning() << __FUNCTION__ << cons->currentItem()->text(0); - - QList<QNetworkConfiguration> configs = manager->allConfigurations(); - foreach(QNetworkConfiguration p, configs) { - if(p.name() == cons->currentItem()->text(0)) { - - sess = new QNetworkSession(p); - - connect(sess, SIGNAL(newConfigurationActivated()), - this, SLOT(getActiveConnections())); - - connect(sess, SIGNAL(stateChanged(QNetworkSession::State)), - this, SLOT(stateChanged(QNetworkSession::State))); - - connect(sess, SIGNAL(error(QNetworkSession::SessionError)), - this, SLOT(networkSessionError(QNetworkSession::SessionError))); - - sess->open(); - } - } -} - -void NMView::getDevices() -{ - qWarning() << ""; - qWarning() << __FUNCTION__; - devicesTreeWidget->clear(); - //qDBusRegisterMetaType<SettingsMap>(); - - if (!dbc.isConnected()) { - qWarning() << "Unable to connect to D-Bus:" << dbc.lastError(); - return; - } - QDBusInterface iface(NM_DBUS_SERVICE, - NM_DBUS_PATH, - NM_DBUS_INTERFACE, - dbc); -//NetworkManager interface - if (!iface.isValid()) { - qWarning() << "Could not find NetworkManager"; - return; - } - -// uint state = iface.property("State").toUInt(); -// switch(state) { -// case NM_STATE_UNKNOWN: -// qWarning() << "State: Unknown"; break; -// case NM_STATE_ASLEEP: -// qWarning() << "State: Asleep"; break; -// case NM_STATE_CONNECTING: -// qWarning() << "State: Connecting"; break; -// case NM_STATE_CONNECTED: -// qWarning() << "State: Connected"; break; -// case NM_STATE_DISCONNECTED: -// qWarning() << "State: Disconnected"; break; -// } - - //get list of network devices - QTreeWidgetItem *item; - QDBusReply<QList<QDBusObjectPath> > reply = iface.call("GetDevices"); - if ( reply.isValid() ) { -// qWarning() << "Current devices:"; - QList<QDBusObjectPath> list = reply.value(); - foreach(QDBusObjectPath path, list) { - QStringList devicesList; - qWarning() << " " << path.path(); - devicesList << path.path(); - - QDBusInterface devIface(NM_DBUS_SERVICE, - path.path(), - NM_DBUS_INTERFACE_DEVICE, - dbc); - if (devIface.isValid()) { - - - - ////// connect the dbus signal -// /*if(*/dbc.connect(NM_DBUS_SERVICE, -// path.path(), -// NM_DBUS_INTERFACE_DEVICE, -// "StateChanged", -// this,SLOT(deviceStateChanged(quint32))); -// { -// qWarning() << "XXXXXXXXXX dbus connect successful" << path.path(); -// } - - - // qWarning() << " Managed: " << devIface.property("Managed").toBool(); - devicesList << devIface.property("Managed").toString(); - // qWarning() << " Interface: " << devIface.property("Interface").toString(); - devicesList << devIface.property("Interface").toString(); - // qWarning() << " HAL UDI: " << devIface.property("Udi").toString(); - // qWarning() << " Driver: " << devIface.property("Driver").toString(); - devicesList << devIface.property("Driver").toString(); - - QString x = deviceTypeToString(devIface.property("DeviceType").toUInt()); - // qWarning() << " Type:" << x; - devicesList << x; - - if( devIface.property("DeviceType").toUInt() == DEVICE_TYPE_802_11_WIRELESS) { - qWarning() << "Device is WIFI"; - // // findAccessPoints(path.path()); - } - - QVariant v = devIface.property("State"); - x = deviceStateToString(v.toUInt()); -// qWarning() << " State:" << x; - devicesList << x; - - quint32 ip = devIface.property("Ip4Address").toUInt(); -// qWarning() << " IP4Address: " << QHostAddress(htonl(ip)).toString(); - devicesList << QHostAddress(htonl(ip)).toString(); - - - if (v.toUInt() == NM_DEVICE_STATE_ACTIVATED) { - QString path = devIface.property("Ip4Config").value<QDBusObjectPath>().path(); -// qWarning() << " IP4Config: " << path; - devicesList << path; - QDBusInterface ipIface(NM_DBUS_SERVICE, - path, - NM_DBUS_INTERFACE_IP4_CONFIG, - dbc); - if (ipIface.isValid()) { - // qWarning() << " Hostname: " << ipIface.property("Hostname").toString(); - devicesList << ipIface.property("Hostname").toString(); -// qWarning() << " Domains: " << ipIface.property("Domains").toStringList(); - devicesList << ipIface.property("Domains").toStringList().join(", "); -// qWarning() << " NisDomain: " << ipIface.property("NisDomain").toString(); - QDBusArgument arg= ipIface.property("Addresses").value<QDBusArgument>(); -// qWarning() << " Addresses: " << ipIface.property("Addresses"); -// qWarning() << " Nameservers: " << ipIface.property("Nameservers"); -// qWarning() << " NisServers: " << ipIface.property("NisServers"); - } - - } - - } - item = new QTreeWidgetItem(devicesList); - devicesTreeWidget->insertTopLevelItem(0, item); - } - } - - -// netconfig(); - -} - -void NMView::readSettings() -{ - QDBusInterface settingsiface(NM_DBUS_SERVICE_SYSTEM_SETTINGS, - NM_DBUS_PATH_SETTINGS, - NM_DBUS_IFACE_SETTINGS, - dbc); - //NetworkManagerSettings interface - if (settingsiface.isValid()) { - QDBusReply<QList<QDBusObjectPath> > reply = settingsiface.call("ListConnections"); - if ( reply.isValid() ) { - QList<QDBusObjectPath> list = reply.value(); - foreach(QDBusObjectPath path, list) { - qWarning() <<__FUNCTION__ << path.path(); - - } - } - } - - QDBusInterface iface(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, dbc); - if (!iface.isValid()) { - qWarning() << "Could not find NetworkManager"; - return; - } - - // QStringList list = item->text().split(" -> "); - - QVariant prop = iface.property("ActiveConnections"); - QList<QDBusObjectPath> connections = prop.value<QList<QDBusObjectPath> >(); - foreach(QDBusObjectPath path, connections) { - QDBusInterface conDetails(NM_DBUS_SERVICE, - path.path(), - NM_DBUS_INTERFACE_ACTIVE_CONNECTION, - dbc); - - if (conDetails.isValid()) { - QString desc = path.path(); - qWarning() << desc; - //if ( item->text(0) == conDetails.property("Connection").value<QDBusObjectPath>().path() ) { - // QListWidgetItem* item = new QTreeWidgetItem( desc, - // cons); - // item->setData(Qt::UserRole, desc); - // activeItemActivated( item ); - //} - } - } -} - -void NMView::printConnectionDetails(const QString& service) -{ - Q_UNUSED(service); - -// -// qWarning() << __FUNCTION__ << service; -// -// QDBusConnection dbc = QDBusConnection::systemBus(); -// if (!dbc.isConnected()) { -// qWarning() << "Unable to connect to D-Bus:" << dbc.lastError(); -// return; -// } -// QDBusInterface allCons(service, -// NM_DBUS_PATH_SETTINGS, -// NM_DBUS_IFACE_SETTINGS, -// dbc); -// -// if (allCons.isValid()) { -// QDBusReply<QList<QDBusObjectPath> > reply = allCons.call("ListConnections"); -// -// if ( reply.isValid() ) { -// qWarning() << "Known connections:"; -// QList<QDBusObjectPath> list = reply.value(); -// -// foreach(QDBusObjectPath path, list) { -// qWarning() << " " << path.path(); -// -// QDBusInterface sysIface(NM_DBUS_SERVICE_SYSTEM_SETTINGS, -// path.path(), -// NM_DBUS_IFACE_SETTINGS_CONNECTION, -// dbc); -// -// if (sysIface.isValid()) { -// QDBusMessage r = sysIface.call("GetSettings"); -// QDBusReply< QSettingsMap > rep = sysIface.call("GetSettings"); -// -// qWarning() << " GetSettings:" << r.arguments() << r.signature() << rep.isValid() << sysIface.lastError(); -// -// QMap< QString, QMap<QString,QVariant> > map = rep.value(); -// QList<QString> list = map.keys(); -// -// foreach (QString key, list) { -// QMap<QString,QVariant> innerMap = map[key]; -// qWarning() << " Key: " << key; -// QMap<QString,QVariant>::const_iterator i = innerMap.constBegin(); -// -// while (i != innerMap.constEnd()) { -// QString k = i.key(); -// qWarning() << " Key: " << k << " Entry: " << i.value(); -// -// if (k == "addresses" && i.value().canConvert<QDBusArgument>()) { -// QDBusArgument arg = i.value().value<QDBusArgument>(); -// arg.beginArray(); -// -// while (!arg.atEnd()) { -// QDBusVariant addr; -// arg >> addr; -// uint ip = addr.variant().toUInt(); -// qWarning() << ip; -// qWarning() << " " << QHostAddress(htonl(ip)).toString(); -// } -// -// } -// i++; -// } -// } -// } -// } -// } -// } - qWarning() << ""; -} - -void NMView::getNetworkDevices() -{ - -} - -void NMView::connectionItemActivated( QTreeWidgetItem * item, int col ) -{ - Q_UNUSED(col); - - qWarning() <<__FUNCTION__<< item->text(0); - QDBusInterface iface(NM_DBUS_SERVICE, - NM_DBUS_PATH, - NM_DBUS_INTERFACE, - dbc); - if (!iface.isValid()) { - qWarning() << "Could not find NetworkManager"; - return; - } - QVariant prop = iface.property("ActiveConnections"); - QList<QDBusObjectPath> connections = prop.value<QList<QDBusObjectPath> >(); - foreach(QDBusObjectPath path, connections) { - QDBusInterface conDetails(NM_DBUS_SERVICE, - path.path(), - NM_DBUS_INTERFACE_ACTIVE_CONNECTION, - dbc); - - if (conDetails.isValid()) { - QString desc = path.path(); - qWarning() << desc; - if ( item->text(0) == conDetails.property("Connection").value<QDBusObjectPath>().path() ) { -// QListWidgetItem* item = new QTreeWidgetItem( desc, -// cons); -// item->setData(Qt::UserRole, desc); -// activeItemActivated( item ); - } - } - } -} - - - -void NMView::deviceItemActivated( QTreeWidgetItem * item , int section) -{ - Q_UNUSED(item); - Q_UNUSED(section); - - // qWarning() << item->text(section) << item->text(4); - //if(item->text(4) == "Wireless") findAccessPoints(item->text(0)); -} - - -void NMView::netconfig() -{ -// qWarning() << __FUNCTION__; - -// qDBusRegisterMetaType<SettingsMap>(); - QDBusConnection dbc = QDBusConnection::systemBus(); - if (!dbc.isConnected()) { - qWarning() << "Unable to connect to D-Bus:" << dbc.lastError(); - return; - } - - QDBusInterface iface(NM_DBUS_SERVICE, - NM_DBUS_PATH, - NM_DBUS_IFACE_SETTINGS_CONNECTION, - dbc); - if (!iface.isValid()) { - qWarning() << "Could not find NetworkManager Settings"; - return; - } else { - QDBusReply<QList<QDBusObjectPath> > reply = iface.call("ListConnections"); - QList<QDBusObjectPath> list = reply.value(); -// qWarning() << reply.value(); - foreach(QDBusObjectPath path, list) { - qWarning() << " " << path.path(); - } - } -} - - -void NMView::findAccessPoints() -{ - accessPointsTreeWidget->clear(); - - QDBusInterface iface(NM_DBUS_SERVICE, - NM_DBUS_PATH, - NM_DBUS_INTERFACE, - dbc); - - QDBusReply<QList<QDBusObjectPath> > reply = iface.call("GetDevices"); - if ( reply.isValid() ) { - QList<QDBusObjectPath> list = reply.value(); - foreach(QDBusObjectPath path, list) { - QDBusInterface devIface(NM_DBUS_SERVICE, - path.path(), - NM_DBUS_INTERFACE_DEVICE, - dbc); - if (devIface.isValid()) { - - if( devIface.property("DeviceType").toUInt() == DEVICE_TYPE_802_11_WIRELESS) { - -// qWarning() <<"deviface"<< devIface.path(); - QDBusInterface wififace(NM_DBUS_SERVICE, - devIface.path(), - NM_DBUS_INTERFACE_DEVICE_WIRELESS, - dbc); - if (!wififace.isValid()) { - qWarning() << "Could not find NetworkManager wireless interface"; - return; - } - -///////////////////////// -// if(dbc.connect(NM_DBUS_SERVICE, -// path.path(), -// NM_DBUS_INTERFACE_DEVICE_WIRELESS, -// "PropertiesChanged", -// this,SLOT(aPPropertiesChanged( QMap<QString,QVariant>))) ) { -// qWarning() << "PropertiesChanged connect"; -// } else { -// qWarning() << "NOT connect"; - -// } -///////////////////////// - qWarning() <<"wififace"<< wififace.path(); - QDBusReply<QList<QDBusObjectPath> > reply2 = wififace.call("GetAccessPoints"); - if ( reply2.isValid() ) { - QTreeWidgetItem *item; - QList<QDBusObjectPath> list2 = reply2.value(); - foreach(QDBusObjectPath path2, list2) { - QDBusInterface accessPointIface(NM_DBUS_SERVICE, - path2.path(), - NM_DBUS_INTERFACE_ACCESS_POINT, - dbc); - if (accessPointIface.isValid()) { -//// qWarning() <<"path2" << path2.path(); - -// if(dbc.connect(NM_DBUS_SERVICE, //signal strength -// path2.path(), -// NM_DBUS_INTERFACE_ACCESS_POINT, -// "PropertiesChanged", -// this,SLOT(aPPropertiesChanged( QMap<QString,QVariant>))) ) { -// qWarning() << "PropertiesChanged connect"; -// } else { -// qWarning() << "NOT connect"; -// -// } - - QStringList accessPoints; - accessPoints << accessPointIface.property("Ssid").toString(); - accessPoints << QString::number(accessPointIface.property("Strength").toInt()); - accessPoints << securityCapabilitiesToString(accessPointIface.property("WpaFlags" ).toInt()); - accessPoints << securityCapabilitiesToString(accessPointIface.property("RsnFlags" ).toInt()); - accessPoints << accessPointIface.property("Frequency" ).toString(); - accessPoints << accessPointIface.property("HwAddress" ).toString(); - accessPoints << deviceModeToString(accessPointIface.property("Mode" ).toInt()); - accessPoints << accessPointIface.property("MaxBitrate" ).toString(); - //HwAddress - // if(accessPointIface.property("Flags" ).toInt() == NM_802_11_AP_FLAGS_PRIVACY ) { - // qWarning() << "Secure"; - // } - item = new QTreeWidgetItem(accessPoints); - accessPointsTreeWidget->insertTopLevelItem(0, item); - } - } - } - } - } - } - } -} - -QString NMView::deviceStateToString(int state) -{ - QString ret; - switch(state) { - case NM_DEVICE_STATE_UNKNOWN: - ret = "Unknown"; - break; - case NM_DEVICE_STATE_UNMANAGED: - ret = "Unmanaged"; - break; - case NM_DEVICE_STATE_UNAVAILABLE: - ret = "Unavailable"; - break; - case NM_DEVICE_STATE_DISCONNECTED: - ret = "Disconnected"; - break; - case NM_DEVICE_STATE_PREPARE: - ret = "Preparing to connect"; - break; - case NM_DEVICE_STATE_CONFIG: - ret = "Being configured"; - break; - case NM_DEVICE_STATE_NEED_AUTH: - ret = "Awaiting secrets"; - break; - case NM_DEVICE_STATE_IP_CONFIG: - ret = "IP requested"; - break; - case NM_DEVICE_STATE_ACTIVATED: - ret = "Activated"; - break; - case NM_DEVICE_STATE_FAILED: - ret = "FAILED"; - break; - }; - return ret; -} - -QString NMView::deviceTypeToString(int device) -{ - QString ret; - switch(device) { - case DEVICE_TYPE_UNKNOWN: - ret = "Unknown"; - break; - case DEVICE_TYPE_802_3_ETHERNET: - ret = "Ethernet"; - break; - case DEVICE_TYPE_802_11_WIRELESS: - ret = "Wireless"; - break; - case DEVICE_TYPE_GSM: - ret = "GSM"; - break; - case DEVICE_TYPE_CDMA: - ret = "CDMA"; - break; - }; - return ret; -} - -QString NMView::securityCapabilitiesToString(int caps) -{ - int check = caps; -// qWarning() << __FUNCTION__<< caps; - QString ret; - if( check == 0 ) - ret += "None."; - if( (check & NM_802_11_AP_SEC_PAIR_WEP40)) - ret += " 40-bit WEP encryption. "; - if( (check & NM_802_11_AP_SEC_PAIR_WEP104) ) - ret += " 104-bit WEP encryption. "; - if( (check & NM_802_11_AP_SEC_PAIR_TKIP) ) - ret += " TKIP encryption. "; - if( (check & NM_802_11_AP_SEC_PAIR_CCMP) ) - ret += " CCMP encryption. "; - if( (check & NM_802_11_AP_SEC_GROUP_WEP40)) - ret += " 40-bit WEP cipher. "; - if( (check & NM_802_11_AP_SEC_GROUP_WEP104)) - ret += " 104-bit WEP cipher. "; - if( (check & NM_802_11_AP_SEC_GROUP_TKIP) ) - ret += " TKIP cipher. "; - if( (check & NM_802_11_AP_SEC_GROUP_CCMP) ) - ret += " CCMP cipher. "; - if( (check & NM_802_11_AP_SEC_KEY_MGMT_PSK)) - ret += " PSK key management. "; - if( (check & NM_802_11_AP_SEC_KEY_MGMT_802_1X) ) - ret += " 802.1x key management. "; - return ret; -} - -QString NMView::deviceModeToString(int mode) -{ - QString ret; - switch (mode) { - case NM_802_11_MODE_UNKNOWN: - ret = "Unknown"; - break; - case NM_802_11_MODE_ADHOC: - ret = " (Adhoc)."; - break; - case NM_802_11_MODE_INFRA: - ret = " (Infrastructure)"; - }; - return ret; -} - -void NMView::netManagerState(quint32 state) -{ - qWarning() << __FUNCTION__ << state;// << old << reason; - switch(state) { - case NM_STATE_UNKNOWN: - qWarning() << "The NetworkManager daemon is in an unknown state. "; - break; - case NM_STATE_ASLEEP: - qWarning() << "The NetworkManager daemon is asleep and all interfaces managed by it are inactive. "; - break; - case NM_STATE_CONNECTING: - qWarning() << "The NetworkManager daemon is connecting a device. FIXME: What does this mean when one device is active and another is connecting? "; - break; - case NM_STATE_CONNECTED: - qWarning() <<"The NetworkManager daemon is connected. "; - break; - case NM_STATE_DISCONNECTED: - qWarning() << "The NetworkManager daemon is disconnected."; - break; - - }; -} - -void NMView::deviceStateChanged(quint32 state) -{ - qWarning() << __FUNCTION__ << state; - switch(state) { - case NM_DEVICE_STATE_UNKNOWN : - qWarning() <<"The device is in an unknown state. "; - break; - case NM_DEVICE_STATE_UNMANAGED: - qWarning() <<"The device is not managed by NetworkManager."; - break; - case NM_DEVICE_STATE_UNAVAILABLE: - qWarning() <<"The device cannot be used (carrier off, rfkill, etc)."; - break; - case NM_DEVICE_STATE_DISCONNECTED: - qWarning() <<"The device is not connected."; - break; - case NM_DEVICE_STATE_PREPARE: - qWarning() <<"The device is preparing to connect."; - break; - case NM_DEVICE_STATE_CONFIG: - qWarning() <<"The device is being configured."; - break; - case NM_DEVICE_STATE_NEED_AUTH: - qWarning() <<"The device is awaiting secrets necessary to continue connection."; - break; - case NM_DEVICE_STATE_IP_CONFIG: - qWarning() <<"The IP settings of the device are being requested and configured."; - break; - case NM_DEVICE_STATE_ACTIVATED: - qWarning() <<"The device is active."; - break; - case NM_DEVICE_STATE_FAILED: - qWarning() <<"The device is in a failure state following an attempt to activate it."; - break; - }; -} - -void NMView::updateCompleted() -{ - qWarning() << __FUNCTION__; -} - -void NMView::newConfigurationActivated() -{ - qWarning() << __FUNCTION__; - getActiveConnections(); -} - -void NMView::stateChanged(QNetworkSession::State state) -{ - // QString stateStringstr; - switch (state) { - case QNetworkSession::Invalid: - stateString = "Invalid session"; - break; - case QNetworkSession::NotAvailable: - stateString = "Session is defined but not yet discovered"; - break; - case QNetworkSession::Connecting: - stateString = "Session is being established"; - break; - case QNetworkSession::Connected: - stateString = "Session is active and can be used for socket operations"; - cons->currentItem()->setText(1, "Active"); - break; - case QNetworkSession::Closing: - stateString = "Session is being shutdown"; - break; - case QNetworkSession::Disconnected: - qWarning() << __FUNCTION__; - manager->updateConfigurations(); - stateString = "Session disconnected"; - cons->currentItem()->setText(1,"Discovered") ; - break; - case QNetworkSession::Roaming: - stateString = "session is roaming from one AP to another"; - break; - }; - qWarning() << __FUNCTION__ << state << stateString; -} - -QString NMView::stateToString(int state) -{ - switch (state) { - case QNetworkConfiguration::Undefined: - return "Undefined"; - break; - case QNetworkConfiguration::Defined: - return "Defined"; - break; - case QNetworkConfiguration::Discovered: - return "Discovered"; - break; - case QNetworkConfiguration::Active: - return "Active"; - break; - }; - return ""; -} - -void NMView::configurationAdded(const QNetworkConfiguration &config) -{ - qWarning() << __FUNCTION__<< config.name() << config.identifier(); -} - -QString NMView::typeToString(int type) -{ - switch(type) { - case QNetworkConfiguration::InternetAccessPoint: - return "Internet AccessPoint"; - break; - case QNetworkConfiguration::ServiceNetwork: - return "Service Network"; - break; - }; - return QString(); -} - -void NMView::aPPropertiesChanged( QMap<QString,QVariant> map) -{ - //QMap<QString, QVariant>::const_iterator iterator = d->values.find(type + QLatin1String("Path")) - QMapIterator<QString, QVariant> i(map); - while (i.hasNext()) { - i.next(); - if( i.key() == "State") { - qWarning() << __FUNCTION__ << i.key() << ": " << i.value().toUInt(); -// deviceStateChanged(i.value().toUInt()); - } else if( i.key() == "ActiveAccessPoint") { - qWarning() << __FUNCTION__ << i.key() << ": " << i.value().value<QDBusObjectPath>().path(); - } else if( i.key() == "Strength") - qWarning() << __FUNCTION__ << i.key() << ": " << i.value().toUInt(); - else - qWarning() << __FUNCTION__ << i.key() << ": " << i.value(); - } -} - -void NMView::networkSessionError(QNetworkSession::SessionError error) -{ - QString errorStr; - switch(error) { - case QNetworkSession::RoamingError: - errorStr = "Roaming error"; - break; - case QNetworkSession::SessionAbortedError: - errorStr = "Session aborted by user or system"; - break; - default: - case QNetworkSession::UnknownSessionError: - errorStr = "Unidentified Error"; - break; - }; - - QMessageBox::warning(this, tr("NMView"), errorStr, QMessageBox::Ok); -} diff --git a/tests/manual/networkmanager/nmview.h b/tests/manual/networkmanager/nmview.h deleted file mode 100644 index 41ee04f..0000000 --- a/tests/manual/networkmanager/nmview.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QWidget> -#include <QDBusConnection> -#include <qnetworkconfigmanager.h> -#include <qnetworksession.h> -#include <qnetworkconfiguration.h> - -#include "ui_dialog.h" - -QT_USE_NAMESPACE - -QT_BEGIN_NAMESPACE -class QListWidget; -class QTreeWidget; -class QTreeWidgetItem; -QT_END_NAMESPACE - -class NMView : public QDialog, private Ui::Dialog -{ - Q_OBJECT -public: - NMView(QDialog* parent = 0); - virtual ~NMView(); - -private: - void init(); - QString stateString; - - QDBusConnection dbc; - void printConnectionDetails(const QString&); - - QString deviceStateToString(int state); - QString deviceTypeToString(int device); - QString securityCapabilitiesToString(int caps); - QString deviceModeToString(int mode); -//QDBusInterface getInterface(); - QNetworkConfigurationManager *manager; - QNetworkSession *sess; - QString stateToString(int state); - QString typeToString(int type); - -private slots: - void update(); - void deactivate(); - void activate(); - void getActiveConnections(); - void updateConnections(); - void getDevices(); - // void readConnectionManagerDetails(); - void getNetworkDevices(); - void connectionItemActivated( QTreeWidgetItem *, int); -// void activeItemActivated( QListWidgetItem *); - void deviceItemActivated( QTreeWidgetItem *, int); - void netconfig(); - void findAccessPoints(); - - void netManagerState(quint32); - void readSettings(); - void updateCompleted(); - void newConfigurationActivated(); - - void stateChanged(QNetworkSession::State); - void deviceStateChanged(quint32 state); - - void configurationAdded(const QNetworkConfiguration &config); - void aPPropertiesChanged( QMap<QString,QVariant> map); - void networkSessionError(QNetworkSession::SessionError); - -}; diff --git a/tests/manual/networkmanager/startdlg.cpp b/tests/manual/networkmanager/startdlg.cpp deleted file mode 100644 index e34b5e9..0000000 --- a/tests/manual/networkmanager/startdlg.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "startdlg.h" -#include <NetworkManager/NetworkManager.h> - - -StartDialog::StartDialog(QWidget * parent) - :QDialog(parent) -{ - QVBoxLayout *layout = new QVBoxLayout(this); - box = new QComboBox(); - layout->addWidget(box); - - QHBoxLayout* hbox = new QHBoxLayout(); - QPushButton* start = new QPushButton("Start"); - connect(start, SIGNAL(clicked()), this, SLOT(accept())); - QPushButton* cancel = new QPushButton("Cancel"); - connect(cancel, SIGNAL(clicked()), this, SLOT(reject())); - - - hbox->addWidget(start); - hbox->addWidget(cancel); - - layout->addLayout(hbox); - - QDBusConnection dbc = QDBusConnection::systemBus(); - if (!dbc.isConnected()) { - qWarning() << "Unable to connect to D-Bus:" << dbc.lastError(); - return; - } - QDBusInterface iface(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, dbc); - if (!iface.isValid()) { - qWarning() << "Could not find NetworkManager"; - return; - } - QDBusReply<QList<QDBusObjectPath> > reply = iface.call("GetDevices"); - if ( reply.isValid() ) { - QList<QDBusObjectPath> list = reply.value(); - foreach(QDBusObjectPath path, list) { - QDBusInterface devIface(NM_DBUS_SERVICE, path.path(), NM_DBUS_INTERFACE_DEVICE, dbc); - if ( devIface.isValid() ) { - box->addItem(devIface.property("Interface").toString(), QVariant(path.path())); - } - } - } -} - -QString StartDialog::device() const -{ - return dev; -} - -void StartDialog::accept() -{ - dev = box->itemData(box->currentIndex(), Qt::UserRole).toString(); - QDialog::accept(); -} diff --git a/tests/manual/repaint/mainwindow/main.cpp b/tests/manual/repaint/mainwindow/main.cpp new file mode 100644 index 0000000..c8524b8 --- /dev/null +++ b/tests/manual/repaint/mainwindow/main.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 <QtGui> +#include "../shared/shared.h" + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QMainWindow mainWindow; + + mainWindow.setCentralWidget(new StaticWidget()); + mainWindow.setStatusBar(new QStatusBar()); + + QDockWidget *dockWidget = new QDockWidget(); + dockWidget->setWidget(new StaticWidget()); + mainWindow.addDockWidget(Qt::LeftDockWidgetArea, dockWidget); + + QToolBar *toolBar = new QToolBar(); + + toolBar->addWidget(new StaticWidget())->setVisible(true);; + + toolBar->addWidget(new QSpinBox())->setVisible(true);; + mainWindow.addToolBar(toolBar); + + mainWindow.resize(600, 400); + mainWindow.show(); + + return app.exec(); +} diff --git a/tests/manual/repaint/mainwindow/mainwindow.pro b/tests/manual/repaint/mainwindow/mainwindow.pro new file mode 100644 index 0000000..c269d57 --- /dev/null +++ b/tests/manual/repaint/mainwindow/mainwindow.pro @@ -0,0 +1,15 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Wed Nov 8 15:46:28 2006 +###################################################################### + +TEMPLATE = app +TARGET = mainwindow +DEPENDPATH += . +INCLUDEPATH += . + +# Input +HEADERS += ../shared/shared.h +SOURCES += main.cpp +CONFIG += qt warn_on debug create_prl link_prl +OBJECTS_DIR = .obj/debug-shared +MOC_DIR = .moc/debug-shared diff --git a/tests/manual/repaint/scrollarea/main.cpp b/tests/manual/repaint/scrollarea/main.cpp new file mode 100644 index 0000000..33a0a1f --- /dev/null +++ b/tests/manual/repaint/scrollarea/main.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 <QtGui> +#include "../shared/shared.h" + + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QScrollArea scrollView; + + QWidget * staticWidget = new StaticWidget(); + staticWidget->resize(400, 200); + scrollView.setWidget(staticWidget); + + scrollView.setAttribute(Qt::WA_StaticContents); + + scrollView.resize(600, 400); + scrollView.show(); + + + return app.exec(); +} + + diff --git a/tests/manual/repaint/scrollarea/scrollarea.pro b/tests/manual/repaint/scrollarea/scrollarea.pro new file mode 100644 index 0000000..e1a40ad --- /dev/null +++ b/tests/manual/repaint/scrollarea/scrollarea.pro @@ -0,0 +1,15 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Wed Nov 8 15:28:57 2006 +###################################################################### + +TEMPLATE = app +TARGET = scrollarea +DEPENDPATH += . +INCLUDEPATH += . + +# Input +HEADERS += ../shared/shared.h +SOURCES += main.cpp +CONFIG += qt warn_on debug create_prl link_prl +OBJECTS_DIR = .obj/debug-shared +MOC_DIR = .moc/debug-shared diff --git a/tests/manual/repaint/shared/shared.h b/tests/manual/repaint/shared/shared.h new file mode 100644 index 0000000..d1caf30 --- /dev/null +++ b/tests/manual/repaint/shared/shared.h @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 <QtGui> +class StaticWidget : public QWidget +{ +Q_OBJECT +public: + int hue; + bool pressed; + StaticWidget(QWidget *parent = 0) + :QWidget(parent) + { + setAttribute(Qt::WA_StaticContents); + setAttribute(Qt::WA_OpaquePaintEvent); + hue = 200; + pressed = false; + } + + // Update 4 rects in a checkerboard pattern, using either + // a QRegion or separate rects (see the useRegion switch) + void updatePattern(QPoint pos) + { + const int rectSize = 10; + QRect rect(pos.x() - rectSize, pos.y() - rectSize, rectSize *2, rectSize * 2); + + QVector<QRect> updateRects; + updateRects.append(rect.translated(rectSize * 2, rectSize * 2)); + updateRects.append(rect.translated(rectSize * 2, -rectSize * 2)); + updateRects.append(rect.translated(-rectSize * 2, rectSize * 2)); + updateRects.append(rect.translated(-rectSize * 2, -rectSize * 2)); + + + bool useRegion = false; + if (useRegion) { + QRegion region; + region.setRects(updateRects.data(), 4); + update(region); + } else { + foreach (QRect rect, updateRects) + update(rect); + } + } + + + void resizeEvent(QResizeEvent *) + { + // qDebug() << "static widget resize from" << e->oldSize() << "to" << e->size(); + } + + void mousePressEvent(QMouseEvent *event) + { +// qDebug() << "mousePress at" << event->pos(); + pressed = true; + updatePattern(event->pos()); + } + + void mouseReleaseEvent(QMouseEvent *) + { + pressed = false; + } + + void mouseMoveEvent(QMouseEvent *event) + { + if (pressed) + updatePattern(event->pos()); + } + + void paintEvent(QPaintEvent *e) + { + QPainter p(this); + static int color = 200; + color = (color + 41) % 205 + 50; +// color = ((color + 45) %150) + 100; + qDebug() << "static widget repaint" << e->rect(); + if (pressed) + p.fillRect(e->rect(), QColor::fromHsv(100, 255, color)); + else + p.fillRect(e->rect(), QColor::fromHsv(hue, 255, color)); + p.setPen(QPen(QColor(Qt::white))); + + for (int y = e->rect().top(); y <= e->rect().bottom() + 1; ++y) { + if (y % 20 == 0) + p.drawLine(e->rect().left(), y, e->rect().right(), y); + } + + for (int x = e->rect().left(); x <= e->rect().right() +1 ; ++x) { + if (x % 20 == 0) + p.drawLine(x, e->rect().top(), x, e->rect().bottom()); + } + } +}; diff --git a/tests/manual/repaint/splitter/main.cpp b/tests/manual/repaint/splitter/main.cpp new file mode 100644 index 0000000..626e826 --- /dev/null +++ b/tests/manual/repaint/splitter/main.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 <QtGui> +#include "../shared/shared.h" + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QSplitter splitter; + + splitter.addWidget(new StaticWidget()); + splitter.addWidget(new StaticWidget()); + + splitter.resize(600, 400); + splitter.show(); + + return app.exec(); +} diff --git a/tests/manual/repaint/splitter/splitter.pro b/tests/manual/repaint/splitter/splitter.pro new file mode 100644 index 0000000..0afc063 --- /dev/null +++ b/tests/manual/repaint/splitter/splitter.pro @@ -0,0 +1,15 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Wed Nov 8 15:39:53 2006 +###################################################################### + +TEMPLATE = app +TARGET = splitter +DEPENDPATH += . +INCLUDEPATH += . + +# Input +HEADERS += ../shared/shared.h +SOURCES += main.cpp +CONFIG += qt warn_on debug create_prl link_prl +OBJECTS_DIR = .obj/debug-shared +MOC_DIR = .moc/debug-shared diff --git a/tests/manual/repaint/tableview/main.cpp b/tests/manual/repaint/tableview/main.cpp new file mode 100644 index 0000000..80d71bc --- /dev/null +++ b/tests/manual/repaint/tableview/main.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 <QtGui> +#include "../shared/shared.h" + +class CellWidget : public QWidget +{ +public: + CellWidget (QWidget *parent = 0) : QWidget(parent) { } + void paintEvent(QPaintEvent * event) + { + static int value = 200; + value = (value + 41) % 205 + 50; + QPainter p(this); + p.fillRect(event->rect(), QColor::fromHsv(100, 255, value)); + } +}; + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + QTableWidget tableWidget; +// tableWidget.setAttribute(Qt::WA_StaticContents); + tableWidget.viewport()->setAttribute(Qt::WA_StaticContents); + tableWidget.setRowCount(15); + tableWidget.setColumnCount(4); + for (int row = 0; row < 15; ++row) + for (int col = 0; col < 4; ++col) +// tableWidget.setCellWidget(row, col, new StaticWidget()); + tableWidget.setCellWidget(row, col, new CellWidget()); + tableWidget.resize(400, 600); + tableWidget.show(); + + + return app.exec(); +} + + diff --git a/tests/manual/repaint/tableview/tableview.pro b/tests/manual/repaint/tableview/tableview.pro new file mode 100644 index 0000000..4fccf4a --- /dev/null +++ b/tests/manual/repaint/tableview/tableview.pro @@ -0,0 +1,8 @@ +HEADERS +=../shared/shared.h +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +# Input +SOURCES += main.cpp diff --git a/tests/manual/repaint/task141091/main.cpp b/tests/manual/repaint/task141091/main.cpp new file mode 100644 index 0000000..3987bfa --- /dev/null +++ b/tests/manual/repaint/task141091/main.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 <QtGui> +#include <QDebug> + +class MyWidget : public QWidget +{ +public: + MyWidget() : QWidget() { + + + setAttribute(Qt::WA_OpaquePaintEvent); + setAttribute(Qt::WA_StaticContents); } +protected: + void paintEvent(QPaintEvent *e) { qDebug() << e->rect(); } +}; + +int main(int argc, char **argv) +{ + QApplication a(argc, argv); + MyWidget w; + w.show(); + return a.exec(); +}
\ No newline at end of file diff --git a/tests/manual/repaint/task141091/task141091.pro b/tests/manual/repaint/task141091/task141091.pro new file mode 100644 index 0000000..db89bd3 --- /dev/null +++ b/tests/manual/repaint/task141091/task141091.pro @@ -0,0 +1,12 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Tue Mar 6 13:44:00 2007 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . +CONFIG+=console + +# Input +SOURCES += main.cpp diff --git a/tests/manual/networkmanager/startdlg.h b/tests/manual/repaint/toplevel/main.cpp index 32c8557..aa7cab3 100644 --- a/tests/manual/networkmanager/startdlg.h +++ b/tests/manual/repaint/toplevel/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -39,21 +39,14 @@ ** ****************************************************************************/ -#include <QDialog> -#include <QtDBus> #include <QtGui> +#include "../shared/shared.h" -class StartDialog : public QDialog +int main(int argc, char **argv) { - Q_OBJECT -public: - StartDialog(QWidget* parent = 0); + QApplication app(argc, argv); + StaticWidget widget; + widget.show(); + return app.exec(); +} - QString device() const; - -public slots: - void accept(); -private: - QString dev; - QComboBox* box; -}; diff --git a/tests/manual/repaint/toplevel/toplevel.pro b/tests/manual/repaint/toplevel/toplevel.pro new file mode 100644 index 0000000..568ea8e --- /dev/null +++ b/tests/manual/repaint/toplevel/toplevel.pro @@ -0,0 +1,16 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Tue Nov 7 10:15:42 2006 +###################################################################### + +TEMPLATE = app +TARGET = toplevel +DEPENDPATH += . +INCLUDEPATH += . +CONFIG += console + +# Input +HEADERS += ../shared/shared.h +SOURCES += main.cpp +CONFIG += qt warn_on debug create_prl link_prl +OBJECTS_DIR = .obj/debug-shared +MOC_DIR = .moc/debug-shared diff --git a/tests/manual/repaint/widget/main.cpp b/tests/manual/repaint/widget/main.cpp new file mode 100644 index 0000000..8c86b2a --- /dev/null +++ b/tests/manual/repaint/widget/main.cpp @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 <QtGui> +#include "../shared/shared.h" + +class Child : public StaticWidget +{ +Q_OBJECT +public: + Child(QWidget *parent) + :StaticWidget(parent) + { + hue = 0; + } +}; + +QWidget *c; + +class TopLevel : public StaticWidget +{ +Q_OBJECT +public: + TopLevel() + { + resizeButton = new QPushButton("resize", this); + connect(resizeButton, SIGNAL(clicked()), SLOT(buttonResizeClicked())); + + movebutton = new QPushButton("move", this); + connect(movebutton, SIGNAL(clicked()), SLOT(buttonMoveClicked())); + movebutton->move(70, 0); + + moveResizebutton = new QPushButton("move + resize", this); + connect(moveResizebutton, SIGNAL(clicked()), SLOT(buttonMoveResizeClicked())); + moveResizebutton->move(150, 0); + + scrollbutton = new QPushButton("scroll", this); + connect(scrollbutton, SIGNAL(clicked()), SLOT(buttonScrollClicked())); + scrollbutton->move(280, 0); + } + +public slots: + void buttonResizeClicked() + { + c->resize(c->size() + QSize(15, 15)); + qDebug() << "child new size" << c->size(); + } + + void buttonMoveClicked() + { + c->move(c->pos() + QPoint(15, 15)); + qDebug() << "child moved" << c->pos(); + } + + void buttonMoveResizeClicked() + { + QRect g = c->geometry(); + g.adjust(15,15,30,30); + c->setGeometry(g); + qDebug() << "child moved" << c->pos() << "rezied" << c->size(); + } + + + void buttonScrollClicked() + { + c->scroll(10, 10); + } + +protected: + QPushButton * resizeButton; + QPushButton * movebutton; + QPushButton * moveResizebutton; + QPushButton * scrollbutton; +}; + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + TopLevel bc; + bc.resize(500, 500); + + c = new Child(&bc); + c->move(100, 100); + c->resize(100, 100); + + QWidget *gc = new StaticWidget(c); + gc->move(20, 20); + gc->resize(50,50); + + + bc.show(); + return app.exec(); +} + +#include "main.moc" + diff --git a/tests/manual/repaint/widget/widget.pro b/tests/manual/repaint/widget/widget.pro new file mode 100644 index 0000000..c9d8f87 --- /dev/null +++ b/tests/manual/repaint/widget/widget.pro @@ -0,0 +1,15 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Tue Nov 7 11:16:05 2006 +###################################################################### + +TEMPLATE = app +TARGET = widget +DEPENDPATH += . +INCLUDEPATH += . + +# Input +HEADERS += ../shared/shared.h +SOURCES += main.cpp +CONFIG += qt warn_on debug create_prl link_prl +OBJECTS_DIR = .obj/debug-shared +MOC_DIR = .moc/debug-shared |