diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-03-16 02:09:27 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-03-16 02:09:27 (GMT) |
commit | dd703f7a7e676f26dcb3ad634d75e0c9f677db43 (patch) | |
tree | f29f903c584349fe7ef67d43613f9fddaeb85aba /tests | |
parent | 081fafe395d52ae42b57c36d1279e6ac05ae2cde (diff) | |
parent | e56c5483fe8b292545bb9f004d796abd8ae00589 (diff) | |
download | Qt-dd703f7a7e676f26dcb3ad634d75e0c9f677db43.zip Qt-dd703f7a7e676f26dcb3ad634d75e0c9f677db43.tar.gz Qt-dd703f7a7e676f26dcb3ad634d75e0c9f677db43.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Conflicts:
src/declarative/qml/qdeclarativeengine.cpp
tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
Diffstat (limited to 'tests')
172 files changed, 4612 insertions, 1211 deletions
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..b212820 100644 --- a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp +++ b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp @@ -58,7 +58,7 @@ private slots: void engineMethod(); void parentContext(); void setContextProperty(); - void addDefaultObject(); + void setContextObject(); void destruction(); void idAsContextProperty(); @@ -224,24 +224,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 +349,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 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..ce505f3 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp @@ -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..78a5e0f 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -207,18 +207,10 @@ class MyDefaultObject1 : public QObject Q_OBJECT 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; } }; 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-enforcerange.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview-enforcerange.qml new file mode 100644 index 0000000..e45c4c3 --- /dev/null +++ b/tests/auto/declarative/qdeclarativegridview/data/gridview-enforcerange.qml @@ -0,0 +1,56 @@ +import Qt 4.6 + +Rectangle { + width: 240 + height: 320 + color: "#ffffff" + Component { + id: myDelegate + Item { + id: wrapper + objectName: "wrapper" + height: 100 + width: 100 + Text { + text: index + } + Text { + y: 25 + id: textName + objectName: "textName" + text: name + } + Text { + y: 50 + id: textNumber + objectName: "textNumber" + text: number + } + Text { + y: 75 + text: wrapper.y + } + } + } + + Component { + id: myHighlight + Rectangle { + color: "lightsteelblue" + } + } + + GridView { + id: grid + objectName: "grid" + width: 240 + height: 320 + model: testModel + delegate: myDelegate + highlight: myHighlight + preferredHighlightBegin: 100 + preferredHighlightEnd: 100 + highlightRangeMode: "StrictlyEnforceRange" + focus: true + } +} 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/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index aeefea1..385d6f5 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -72,6 +72,7 @@ private slots: void modelChanges(); void positionViewAtIndex(); void resetModel(); + void enforceRange(); void QTBUG_8456(); private: @@ -702,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; } @@ -943,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 @@ -957,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 @@ -971,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 @@ -985,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 @@ -998,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; } @@ -1042,6 +1089,53 @@ void tst_QDeclarativeGridView::resetModel() } } +void tst_QDeclarativeGridView::enforceRange() +{ + QDeclarativeView *canvas = createView(); + + TestModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview-enforcerange.qml")); + qApp->processEvents(); + + QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); + QVERIFY(gridview != 0); + + QCOMPARE(gridview->preferredHighlightBegin(), 100.0); + QCOMPARE(gridview->preferredHighlightEnd(), 100.0); + QCOMPARE(gridview->highlightRangeMode(), QDeclarativeGridView::StrictlyEnforceRange); + + QDeclarativeItem *viewport = gridview->viewport(); + QVERIFY(viewport != 0); + + // view should be positioned at the top of the range. + QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 0); + QVERIFY(item); + QCOMPARE(gridview->contentY(), -100.0); + + QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 0); + QVERIFY(name != 0); + QCOMPARE(name->text(), model.name(0)); + QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 0); + QVERIFY(number != 0); + QCOMPARE(number->text(), model.number(0)); + + // Check currentIndex is updated when viewport moves + gridview->setContentY(0); + QCOMPARE(gridview->currentIndex(), 2); + + gridview->setCurrentIndex(5); + QTest::qWait(500); + QCOMPARE(gridview->contentY(), 100.); + + delete canvas; +} + void tst_QDeclarativeGridView::QTBUG_8456() { QDeclarativeView *canvas = createView(); 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/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..45d670f 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> @@ -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/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/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index 29323a7..95ac2c0 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -269,9 +269,8 @@ void tst_QDeclarativeListModel::dynamic() QDeclarativeEngine engine; QDeclarativeListModel model; - QDeclarativeEngine::setContextForObject(&model, engine.rootContext()); - engine.rootContext()->addDefaultObject(&model); - + QDeclarativeEngine::setContextForObject(&model,engine.rootContext()); + engine.rootContext()->setContextObject(&model); QDeclarativeExpression e(engine.rootContext(), script, &model); if (!warning.isEmpty()) QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); diff --git a/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp b/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp index 1b7af19..f3c72d1 100644 --- a/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp +++ b/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp @@ -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/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 75fbbf8..5b57487 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -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; } @@ -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; } diff --git a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp index 818f108..279a9b7 100644 --- a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp +++ b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp @@ -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/qdeclarativeparticles/data/particlemotion.qml b/tests/auto/declarative/qdeclarativeparticles/data/particlemotion.qml index ace61fe..f1e4909 100644 --- a/tests/auto/declarative/qdeclarativeparticles/data/particlemotion.qml +++ b/tests/auto/declarative/qdeclarativeparticles/data/particlemotion.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/particles.qml index 0d42645..4f168a9 100644 --- a/tests/auto/declarative/qdeclarativeparticles/data/particles.qml +++ b/tests/auto/declarative/qdeclarativeparticles/data/particles.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..f4e9a27 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 { @@ -67,73 +67,75 @@ void tst_QDeclarativeParticles::properties() { QDeclarativeView *canvas = createView(SRCDIR "/data/particles.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"); 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); @@ -144,42 +146,44 @@ void tst_QDeclarativeParticles::motionWander() { QDeclarativeView *canvas = createView(SRCDIR "/data/particlemotion.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); @@ -190,7 +194,8 @@ void tst_QDeclarativeParticles::runs() { QDeclarativeView *canvas = createView(SRCDIR "/data/particles.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/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..cc1a8d5 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -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); @@ -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; diff --git a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp index 9b8a643..76c5403 100644 --- a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp +++ b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp @@ -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/tst_qdeclarativerepeater.cpp b/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp index 7a97e60..7da9454 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) diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index 8d3ca7a..eb0e2bd 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) 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/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/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/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/multimedia.pro b/tests/auto/multimedia.pro index 9cfae84..f55d6e4 100644 --- a/tests/auto/multimedia.pro +++ b/tests/auto/multimedia.pro @@ -6,6 +6,7 @@ SUBDIRS=\ qaudioformat \ qaudioinput \ qaudiooutput \ + qsoundeffect \ qdeclarativeaudio \ qdeclarativevideo \ qgraphicsvideoitem \ diff --git a/tests/auto/q3listview/tst_q3listview.cpp b/tests/auto/q3listview/tst_q3listview.cpp index 4de6f95..56fa25f 100644 --- a/tests/auto/q3listview/tst_q3listview.cpp +++ b/tests/auto/q3listview/tst_q3listview.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include <iostream> #include <QtTest/QtTest> @@ -87,6 +88,8 @@ public slots: private slots: void getSetCheck(); void sortchild(); + void sortchild2(); // item -> item -> 3 items + void sortchild3(); // item -> 3 items void takeItem_data(); void takeItem(); void selections_mouseClick_data(); @@ -262,7 +265,7 @@ void tst_Q3ListView::sortchild() QVERIFY( item == item1 ); listview->setSorting( 0, FALSE ); - + item = listview->firstChild(); QVERIFY( item == item1 ); item = item->itemBelow(); @@ -291,6 +294,127 @@ void tst_Q3ListView::sortchild() delete listview; } +void tst_Q3ListView::sortchild2() +{ + Q3ListView* listview = new Q3ListView( 0 ); + + listview->addColumn( "" ); + + Q3ListViewItem* item1 = new Q3ListViewItem( listview, "zzz" ); + Q3ListViewItem* item2 = new Q3ListViewItem( listview, "hhh" ); + Q3ListViewItem* item3 = new Q3ListViewItem( listview, "bbb" ); + Q3ListViewItem* item4 = new Q3ListViewItem( listview, "jjj" ); + Q3ListViewItem* item5 = new Q3ListViewItem( listview, "ddd" ); + Q3ListViewItem* item6 = new Q3ListViewItem( listview, "lll" ); + + Q3ListViewItem* item31 = new Q3ListViewItem( item3, "bbb-level2" ); + + Q3ListViewItem* item31b = new Q3ListViewItem( item31, "234" ); + Q3ListViewItem* item31c = new Q3ListViewItem( item31, "345" ); + Q3ListViewItem* item31a = new Q3ListViewItem( item31, "123" ); + + listview->setOpen( item3, TRUE ); + listview->setOpen( item31, TRUE ); + + listview->setSorting( 0, TRUE ); + listview->show(); + + Q3ListViewItem *item = listview->firstChild(); + QVERIFY( item == item3 ); + item = item->itemBelow(); + QVERIFY( item == item31 ); + item = item->itemBelow(); + QVERIFY( item == item31a ); + item = item->itemBelow(); + QVERIFY( item == item31b ); + item = item->itemBelow(); + QVERIFY( item == item31c ); + item = item->itemBelow(); + QVERIFY( item == item5 ); + item = item->itemBelow(); + QVERIFY( item == item2 ); + item = item->itemBelow(); + QVERIFY( item == item4 ); + item = item->itemBelow(); + QVERIFY( item == item6 ); + item = item->itemBelow(); + QVERIFY( item == item1 ); + + listview->setSorting( 0, FALSE ); + + item = listview->firstChild(); + QVERIFY( item == item1 ); + item = item->itemBelow(); + QVERIFY( item == item6 ); + item = item->itemBelow(); + QVERIFY( item == item4 ); + item = item->itemBelow(); + QVERIFY( item == item2 ); + item = item->itemBelow(); + QVERIFY( item == item5 ); + item = item->itemBelow(); + QVERIFY( item == item3 ); + item = item->itemBelow(); + QVERIFY( item == item31 ); + item = item->itemBelow(); + QVERIFY( item == item31c ); + item = item->itemBelow(); + QVERIFY( item == item31b ); + item = item->itemBelow(); + QVERIFY( item == item31a ); + + item = listview->firstChild(); + item->moveItem( item->itemBelow() ); + + listview->setSorting( 0, FALSE ); + QVERIFY( item == listview->firstChild() ); + + delete listview; +} + +void tst_Q3ListView::sortchild3() +{ + Q3ListView* listview = new Q3ListView( 0 ); + + listview->addColumn( "" ); + + Q3ListViewItem* item3 = new Q3ListViewItem( listview, "bbb" ); + + + Q3ListViewItem* item31b = new Q3ListViewItem( item3, "234" ); + Q3ListViewItem* item31c = new Q3ListViewItem( item3, "345" ); + Q3ListViewItem* item31a = new Q3ListViewItem( item3, "123" ); + + listview->setOpen( item3, TRUE ); + + listview->setSorting( 0, TRUE ); + listview->show(); + + Q3ListViewItem *item = listview->firstChild(); + QVERIFY( item == item3 ); + item = item->itemBelow(); + QVERIFY( item == item31a ); + item = item->itemBelow(); + QVERIFY( item == item31b ); + item = item->itemBelow(); + QVERIFY( item == item31c ); + item = item->itemBelow(); + + listview->setSorting( 0, FALSE ); + + item = listview->firstChild(); + QVERIFY( item == item3 ); + item = item->itemBelow(); + QVERIFY( item == item31c ); + item = item->itemBelow(); + QVERIFY( item == item31b ); + item = item->itemBelow(); + QVERIFY( item == item31a ); + + delete listview; +} + + void tst_Q3ListView::takeItem_data() { QTest::addColumn<Q3ListView::SelectionMode>("selectionMode"); 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/qchar/tst_qchar.cpp b/tests/auto/qchar/tst_qchar.cpp index 547147c..6227c2e 100644 --- a/tests/auto/qchar/tst_qchar.cpp +++ b/tests/auto/qchar/tst_qchar.cpp @@ -72,6 +72,7 @@ private slots: void toLower(); void toTitle(); void toCaseFolded(); + void isPrint(); void isUpper(); void isLower(); void category(); @@ -218,6 +219,12 @@ void tst_QChar::toCaseFolded() QVERIFY(QChar::toCaseFolded((ushort)0xb5) == 0x3bc); } +void tst_QChar::isPrint() +{ + QVERIFY(QChar('A').isPrint()); + QVERIFY(!QChar(0x1aff).isPrint()); // General_Gategory =Cn +} + void tst_QChar::isUpper() { QVERIFY(QChar('A').isUpper()); @@ -259,6 +266,12 @@ void tst_QChar::category() QVERIFY(QChar::category(0xd900u) == QChar::Other_Surrogate); QVERIFY(QChar::category(0xdc00u) == QChar::Other_Surrogate); QVERIFY(QChar::category(0xdc01u) == QChar::Other_Surrogate); + + QVERIFY(QChar::category((uint)0x10fffdu) == QChar::Other_PrivateUse); + QVERIFY(QChar::category((uint)0x110000u) == QChar::NoCategory); + + QVERIFY(QChar::category((uint)0x1aff) == QChar::Other_NotAssigned); + QVERIFY(QChar::category((uint)0x10ffffu) == QChar::Other_NotAssigned); } void tst_QChar::direction() diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index d89e463..8ee494f 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -227,12 +227,12 @@ void tst_QGL::getSetCheck() QCOMPARE(false, obj1.alpha()); QVERIFY(!obj1.testOption(QGL::AlphaChannel)); QVERIFY(obj1.testOption(QGL::NoAlphaChannel)); - obj1.setAlphaBufferSize(0); + obj1.setAlphaBufferSize(1); QCOMPARE(true, obj1.alpha()); // setAlphaBufferSize() enables alpha. - QCOMPARE(0, obj1.alphaBufferSize()); + QCOMPARE(1, obj1.alphaBufferSize()); QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size -2147483648"); obj1.setAlphaBufferSize(TEST_INT_MIN); - QCOMPARE(0, obj1.alphaBufferSize()); // Makes no sense with a negative buffer size + QCOMPARE(1, obj1.alphaBufferSize()); // Makes no sense with a negative buffer size obj1.setAlphaBufferSize(3); QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size -1"); obj1.setAlphaBufferSize(-1); @@ -243,11 +243,11 @@ void tst_QGL::getSetCheck() // int QGLFormat::stencilBufferSize() // void QGLFormat::setStencilBufferSize(int) QCOMPARE(-1, obj1.stencilBufferSize()); - obj1.setStencilBufferSize(0); - QCOMPARE(0, obj1.stencilBufferSize()); + obj1.setStencilBufferSize(1); + QCOMPARE(1, obj1.stencilBufferSize()); QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size -2147483648"); obj1.setStencilBufferSize(TEST_INT_MIN); - QCOMPARE(0, obj1.stencilBufferSize()); // Makes no sense with a negative buffer size + QCOMPARE(1, obj1.stencilBufferSize()); // Makes no sense with a negative buffer size obj1.setStencilBufferSize(3); QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size -1"); obj1.setStencilBufferSize(-1); @@ -352,6 +352,7 @@ void tst_QGL::getSetCheck() // bool QGLFormat::accum() // void QGLFormat::setAccum(bool) + obj1.setAccumBufferSize(0); QCOMPARE(false, obj1.accum()); QVERIFY(!obj1.testOption(QGL::AccumBuffer)); QVERIFY(obj1.testOption(QGL::NoAccumBuffer)); @@ -1401,8 +1402,8 @@ void tst_QGL::glWidgetRenderPixmap() QImage reference(fb.size(), QImage::Format_RGB32); reference.fill(0xffff0000); -#ifdef QGL_EGL - QSKIP("renderPixmap() not yet supported under EGL", SkipAll); +#if defined(QGL_EGL) && !defined(Q_WS_X11) + QSKIP("renderPixmap() not yet supported under EGL on your platform", SkipAll); #endif QFUZZY_COMPARE_IMAGES(fb, reference); diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp index 58b1a48..4b56f77 100644 --- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp @@ -85,6 +85,9 @@ private slots: void sessionOpenCloseStop_data(); void sessionOpenCloseStop(); + void sessionAutoClose_data(); + void sessionAutoClose(); + private: QNetworkConfigurationManager manager; @@ -1202,7 +1205,67 @@ bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration) { return true; } +void tst_QNetworkSession::sessionAutoClose_data() +{ + QTest::addColumn<QNetworkConfiguration>("configuration"); + + bool testData = false; + foreach (const QNetworkConfiguration &config, + manager.allConfigurations(QNetworkConfiguration::Discovered)) { + QNetworkSession session(config); + if (!session.sessionProperty(QLatin1String("AutoCloseSessionTimeout")).isValid()) + continue; + + testData = true; + + const QString name = config.name().isEmpty() ? QString("<Hidden>") : config.name(); + QTest::newRow(name.toLocal8Bit().constData()) << config; + } + + if (!testData) + QSKIP("No applicable configurations to test", SkipAll); +} + +void tst_QNetworkSession::sessionAutoClose() +{ + QFETCH(QNetworkConfiguration, configuration); + + QNetworkSession session(configuration); + + QVERIFY(session.configuration() == configuration); + QVariant autoCloseSession = session.sessionProperty(QLatin1String("AutoCloseSessionTimeout")); + + QVERIFY(autoCloseSession.isValid()); + + // property defaults to false + QCOMPARE(autoCloseSession.toInt(), -1); + + QSignalSpy closeSpy(&session, SIGNAL(closed())); + + session.open(); + session.waitForOpened(); + + if (!session.isOpen()) + QSKIP("Session not open", SkipSingle); + + // set session to auto close at next polling interval. + session.setSessionProperty(QLatin1String("AutoCloseSessionTimeout"), 0); + + QTRY_VERIFY(!closeSpy.isEmpty()); + + QCOMPARE(session.state(), QNetworkSession::Connected); + + QVERIFY(!session.isOpen()); + + QVERIFY(session.configuration() == configuration); + + autoCloseSession = session.sessionProperty(QLatin1String("AutoCloseSessionTimeout")); + + QVERIFY(autoCloseSession.isValid()); + + QCOMPARE(autoCloseSession.toInt(), -1); +} QTEST_MAIN(tst_QNetworkSession) diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index a03b2c7..701dc2e 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -999,10 +999,10 @@ void tst_QPainter::drawPixmapFragments() { QPixmap origPixmap(20, 20); QPixmap resPixmap(20, 20); - QPainter::Fragment fragments[4] = { {15, 15, 0, 0, 10, 10, 1, 1, 0, 1}, - { 5, 15, 10, 0, 10, 10, 1, 1, 0, 1}, - {15, 5, 0, 10, 10, 10, 1, 1, 0, 1}, - { 5, 5, 10, 10, 10, 10, 1, 1, 0, 1} }; + QPainter::PixmapFragment fragments[4] = { {15, 15, 0, 0, 10, 10, 1, 1, 0, 1}, + { 5, 15, 10, 0, 10, 10, 1, 1, 0, 1}, + {15, 5, 0, 10, 10, 10, 1, 1, 0, 1}, + { 5, 5, 10, 10, 10, 10, 1, 1, 0, 1} }; { QPainter p(&origPixmap); p.fillRect(0, 0, 10, 10, Qt::red); @@ -1025,7 +1025,7 @@ void tst_QPainter::drawPixmapFragments() QVERIFY(resImage.pixel(15, 15) == origImage.pixel(5, 5)); - QPainter::Fragment fragment = QPainter::Fragment::create(QPointF(20, 20), QRectF(30, 30, 2, 2)); + QPainter::PixmapFragment fragment = QPainter::PixmapFragment::create(QPointF(20, 20), QRectF(30, 30, 2, 2)); QVERIFY(fragment.x == 20); QVERIFY(fragment.y == 20); QVERIFY(fragment.sourceLeft == 30); diff --git a/tests/auto/qsoundeffect/qsoundeffect.pro b/tests/auto/qsoundeffect/qsoundeffect.pro new file mode 100644 index 0000000..eaa35b2 --- /dev/null +++ b/tests/auto/qsoundeffect/qsoundeffect.pro @@ -0,0 +1,20 @@ +load(qttest_p4) + +SOURCES += tst_qsoundeffect.cpp + +QT = core multimedia + +wince* { + deploy.sources += 4.wav + DEPLOYMENT = deploy + DEFINES += SRCDIR=\\\"\\\" + QT += gui +} else { + DEFINES += SRCDIR=\\\"$$PWD/\\\" +} + +unix:!mac { + !contains(QT_CONFIG, pulseaudio) { + DEFINES += QT_MULTIMEDIA_QMEDIAPLAYER + } +} diff --git a/tests/auto/qsoundeffect/test.wav b/tests/auto/qsoundeffect/test.wav Binary files differnew file mode 100644 index 0000000..e4088a9 --- /dev/null +++ b/tests/auto/qsoundeffect/test.wav diff --git a/tests/auto/qsoundeffect/tst_qsoundeffect.cpp b/tests/auto/qsoundeffect/tst_qsoundeffect.cpp new file mode 100644 index 0000000..b918816 --- /dev/null +++ b/tests/auto/qsoundeffect/tst_qsoundeffect.cpp @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** 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 <QtTest/QtTest> +#include <QtCore/qlocale.h> +#include <qaudiooutput.h> +#include <qaudiodeviceinfo.h> +#include <qaudio.h> +#include <private/qsoundeffect_p.h> + + +class tst_QSoundEffect : public QObject +{ + Q_OBJECT +public: + tst_QSoundEffect(QObject* parent=0) : QObject(parent) {} + +private slots: + void initTestCase(); + void testSource(); + void testLooping(); + void testVolume(); + void testMuting(); + +private: + QSoundEffect* sound; +}; + +void tst_QSoundEffect::initTestCase() +{ +#ifndef QT_MULTIMEDIA_QMEDIAPLAYER + sound = new QSoundEffect; + + QVERIFY(sound->source().isEmpty()); + QVERIFY(sound->loopCount() == 1); + QVERIFY(sound->volume() == 100); + QVERIFY(sound->isMuted() == false); +#endif +} + +void tst_QSoundEffect::testSource() +{ +#ifndef QT_MULTIMEDIA_QMEDIAPLAYER + QSignalSpy readSignal(sound, SIGNAL(sourceChanged())); + + QUrl url = QUrl::fromLocalFile(QString("%1%2").arg(SRCDIR).arg("test.wav")); + sound->setSource(url); + + QCOMPARE(sound->source(),url); + QCOMPARE(readSignal.count(),1); + + QTestEventLoop::instance().enterLoop(1); + sound->play(); + + QTest::qWait(3000); +#endif +} + +void tst_QSoundEffect::testLooping() +{ +#ifndef QT_MULTIMEDIA_QMEDIAPLAYER + QSignalSpy readSignal(sound, SIGNAL(loopCountChanged())); + + sound->setLoopCount(5); + QCOMPARE(sound->loopCount(),5); + + sound->play(); + + // test.wav is about 200ms, wait until it has finished playing 5 times + QTest::qWait(3000); +#endif +} + +void tst_QSoundEffect::testVolume() +{ +#ifndef QT_MULTIMEDIA_QMEDIAPLAYER + QSignalSpy readSignal(sound, SIGNAL(volumeChanged())); + + sound->setVolume(50); + QCOMPARE(sound->volume(),50); + + QTest::qWait(20); + QCOMPARE(readSignal.count(),1); +#endif +} + +void tst_QSoundEffect::testMuting() +{ +#ifndef QT_MULTIMEDIA_QMEDIAPLAYER + QSignalSpy readSignal(sound, SIGNAL(mutedChanged())); + + sound->setMuted(true); + QCOMPARE(sound->isMuted(),true); + + QTest::qWait(20); + QCOMPARE(readSignal.count(),1); + + delete sound; +#endif +} + +QTEST_MAIN(tst_QSoundEffect) + +#include "tst_qsoundeffect.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/qsvggenerator/referenceSvgs/fileName_output.svg b/tests/auto/qsvggenerator/referenceSvgs/fileName_output.svg index 99926b3..f1f9e35 100644 --- a/tests/auto/qsvggenerator/referenceSvgs/fileName_output.svg +++ b/tests/auto/qsvggenerator/referenceSvgs/fileName_output.svg @@ -4,12 +4,12 @@ <desc>Generated with Qt</desc> <defs> </defs> -<g fill="none" stroke="black" vector-effect="non-scaling-stroke" stroke-width="1" fill-rule="evenodd" stroke-linecap="square" stroke-linejoin="bevel" > +<g fill="none" stroke="black" stroke-width="1" fill-rule="evenodd" stroke-linecap="square" stroke-linejoin="bevel" > <g fill="#ff0000" fill-opacity="1" stroke="none" transform="matrix(1,0,0,1,0,0)" -font-family="Arial" font-size="11pt" font-weight="400" font-style="normal" +font-family="Sans Serif" font-size="8.25" font-weight="400" font-style="normal" > -<path fill-rule="evenodd" d="M0,0 L100,0 L100,100 L0,100 L0,0"/> +<path vector-effect="non-scaling-stroke" fill-rule="evenodd" d="M0,0 L100,0 L100,100 L0,100 L0,0"/> </g> </g> </svg> diff --git a/tests/auto/qsvggenerator/referenceSvgs/radial_gradient.svg b/tests/auto/qsvggenerator/referenceSvgs/radial_gradient.svg index f61dd40..84afbf3 100644 --- a/tests/auto/qsvggenerator/referenceSvgs/radial_gradient.svg +++ b/tests/auto/qsvggenerator/referenceSvgs/radial_gradient.svg @@ -13,18 +13,18 @@ <stop offset="1" stop-color="#0000ff" stop-opacity="1" /> </radialGradient> </defs> -<g fill="none" stroke="black" vector-effect="non-scaling-stroke" stroke-width="1" fill-rule="evenodd" stroke-linecap="square" stroke-linejoin="bevel" > +<g fill="none" stroke="black" stroke-width="1" fill-rule="evenodd" stroke-linecap="square" stroke-linejoin="bevel" > <g fill="url(#gradient1)" stroke="none" transform="matrix(1,0,0,1,0,0)" -font-family="Sans Serif" font-size="9pt" font-weight="400" font-style="normal" +font-family="Sans Serif" font-size="8.25" font-weight="400" font-style="normal" > -<path fill-rule="evenodd" d="M0,0 L100,0 L100,100 L0,100 L0,0"/> +<path vector-effect="non-scaling-stroke" fill-rule="evenodd" d="M0,0 L100,0 L100,100 L0,100 L0,0"/> </g> <g fill="url(#gradient2)" stroke="none" transform="matrix(1,0,0,1,0,0)" -font-family="Sans Serif" font-size="9pt" font-weight="400" font-style="normal" +font-family="Sans Serif" font-size="8.25" font-weight="400" font-style="normal" > -<path fill-rule="evenodd" d="M100,0 L200,0 L200,100 L100,100 L100,0"/> +<path vector-effect="non-scaling-stroke" fill-rule="evenodd" d="M100,0 L200,0 L200,100 L100,100 L100,0"/> </g> </g> </svg> diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp index 16dd2b4..106fd8c 100644 --- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp +++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp @@ -74,6 +74,7 @@ private slots: void nestedQXmlStreamReader() const; void stylePropagation() const; void matrixForElement() const; + void boundsOnElement() const; void gradientStops() const; void gradientRefs(); void fillRule(); @@ -470,6 +471,36 @@ void tst_QSvgRenderer::matrixForElement() const compareTransforms(QTransform(painter.worldMatrix()), QTransform(renderer.matrixForElement(QLatin1String("firkant")))); } +void tst_QSvgRenderer::boundsOnElement() const +{ + QByteArray data("<svg>" + "<g id=\"prim\" transform=\"translate(-3,1)\">" + "<g id=\"sjokade\" stroke=\"none\" stroke-width=\"10\">" + "<rect id=\"kaviar\" transform=\"rotate(45)\" x=\"-10\" y=\"-10\" width=\"20\" height=\"20\"/>" + "</g>" + "<g id=\"nugatti\" stroke=\"black\" stroke-width=\"2\">" + "<use x=\"0\" y=\"0\" transform=\"rotate(45)\" xlink:href=\"#kaviar\"/>" + "</g>" + "<g id=\"nutella\" stroke=\"none\" stroke-width=\"10\">" + "<path id=\"baconost\" transform=\"rotate(45)\" d=\"M-10 -10 L10 -10 L10 10 L-10 10 Z\"/>" + "</g>" + "<g id=\"hapaa\" transform=\"translate(-2,2)\" stroke=\"black\" stroke-width=\"2\">" + "<use x=\"0\" y=\"0\" transform=\"rotate(45)\" xlink:href=\"#baconost\"/>" + "</g>" + "</g>" + "</svg>"); + + qreal sqrt2 = qSqrt(2); + QSvgRenderer renderer(data); + QCOMPARE(renderer.boundsOnElement(QLatin1String("sjokade")), QRectF(-10 * sqrt2, -10 * sqrt2, 20 * sqrt2, 20 * sqrt2)); + QCOMPARE(renderer.boundsOnElement(QLatin1String("kaviar")), QRectF(-10 * sqrt2, -10 * sqrt2, 20 * sqrt2, 20 * sqrt2)); + QCOMPARE(renderer.boundsOnElement(QLatin1String("nugatti")), QRectF(-11, -11, 22, 22)); + QCOMPARE(renderer.boundsOnElement(QLatin1String("nutella")), QRectF(-10 * sqrt2, -10 * sqrt2, 20 * sqrt2, 20 * sqrt2)); + QCOMPARE(renderer.boundsOnElement(QLatin1String("baconost")), QRectF(-10 * sqrt2, -10 * sqrt2, 20 * sqrt2, 20 * sqrt2)); + QCOMPARE(renderer.boundsOnElement(QLatin1String("hapaa")), QRectF(-13, -9, 22, 22)); + QCOMPARE(renderer.boundsOnElement(QLatin1String("prim")), QRectF(-10 * sqrt2 - 3, -10 * sqrt2 + 1, 20 * sqrt2, 20 * sqrt2)); +} + void tst_QSvgRenderer::gradientStops() const { { 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/qtextcodec/test/test.pro b/tests/auto/qtextcodec/test/test.pro index afd7f5e..efa2e85 100644 --- a/tests/auto/qtextcodec/test/test.pro +++ b/tests/auto/qtextcodec/test/test.pro @@ -27,6 +27,7 @@ wince*: { DEFINES += SRCDIR=\\\"\\\" }else:symbian { # Symbian can't define SRCDIR meaningfully here + LIBS += -lcharconv -lconvnames -lgb2312_shared -ljisx0201 -ljisx0208 -lefsrv } else { DEFINES += SRCDIR=\\\"$$PWD/../\\\" } diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp index aa97e87..1c64ade 100644 --- a/tests/auto/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp @@ -99,6 +99,13 @@ private slots: #ifdef Q_OS_UNIX void toLocal8Bit(); #endif + + void invalidNames(); + void checkAliases_data(); + void checkAliases(); + + void moreToFromUnicode_data(); + void moreToFromUnicode(); }; void tst_QTextCodec::toUnicode_data() @@ -119,6 +126,7 @@ void tst_QTextCodec::toUnicode() if ( file.open( QIODevice::ReadOnly ) ) { QByteArray ba = file.readAll(); + QVERIFY(!ba.isEmpty()); QTextCodec *c = QTextCodec::codecForName( codecName.toLatin1() ); QVERIFY(c != 0); QString uniString = c->toUnicode( ba ); @@ -126,6 +134,7 @@ void tst_QTextCodec::toUnicode() QCOMPARE(uniString, QString::fromUtf8(ba)); QCOMPARE(ba, uniString.toUtf8()); } + QVERIFY(!uniString.isEmpty()); QCOMPARE( ba, c->fromUnicode( uniString ) ); if (codecName == QLatin1String("eucKR")) { @@ -185,7 +194,9 @@ void tst_QTextCodec::fromUnicode_data() QTest::newRow("data16") << "ISO-8859-16" << true; QTest::newRow("data18") << "IBM850" << true; +#ifndef Q_OS_SYMBIAN //symbian implementation will return empty string if all char are invalid QTest::newRow("data19") << "IBM874" << true; +#endif QTest::newRow("data20") << "IBM866" << true; QTest::newRow("data21") << "windows-1250" << true; @@ -193,7 +204,9 @@ void tst_QTextCodec::fromUnicode_data() QTest::newRow("data23") << "windows-1252" << true; QTest::newRow("data24") << "windows-1253" << true; QTest::newRow("data25") << "windows-1254" << true; +#ifndef Q_OS_SYMBIAN //symbian implementation will return empty string if all char are invalid QTest::newRow("data26") << "windows-1255" << true; +#endif QTest::newRow("data27") << "windows-1256" << true; QTest::newRow("data28") << "windows-1257" << true; QTest::newRow("data28") << "windows-1258" << true; @@ -205,6 +218,39 @@ void tst_QTextCodec::fromUnicode_data() QTest::newRow("data32") << "SJIS" << false; QTest::newRow("data33") << "EUC-KR" << false; + + // all codecs from documentation + QTest::newRow("doc2") << "Big5" << false; + QTest::newRow("doc3") << "Big5-HKSCS" << false; + QTest::newRow("doc4") << "CP949" << false; + QTest::newRow("doc5") << "EUC-JP" << false; + QTest::newRow("doc6") << "EUC-KR" << false; + //QTest::newRow("doc7") << "GB18030-0" << false; // only GB18030 works + QTest::newRow("doc7-bis") << "GB18030" << false; + QTest::newRow("doc8") << "IBM 850" << false; + QTest::newRow("doc9") << "IBM 866" << false; + QTest::newRow("doc10") << "IBM 874" << false; + QTest::newRow("doc11") << "ISO 2022-JP" << false; + //ISO 8859-1 to 10 and ISO 8859-13 to 16 tested previously + // Iscii-Bng, Dev, Gjr, Knd, Mlm, Ori, Pnj, Tlg, and Tml tested in Iscii test + //QTest::newRow("doc12") << "JIS X 0201" << false; //actually not there + //QTest::newRow("doc13") << "JIS X 0208" << false; // actually not there + QTest::newRow("doc14") << "KOI8-R" << false; + QTest::newRow("doc15") << "KOI8-U" << false; + //QTest::newRow("doc16") << "MuleLao-1" << false; //only on x11 + QTest::newRow("doc17") << "ROMAN8" << false; + QTest::newRow("doc18") << "Shift-JIS" << false; + QTest::newRow("doc19") << "TIS-620" << false; + QTest::newRow("doc20") << "TSCII" << false; + QTest::newRow("doc21") << "UTF-8" << false; + QTest::newRow("doc22") << "UTF-16" << false; + QTest::newRow("doc23") << "UTF-16BE" << false; + QTest::newRow("doc24") << "UTF-16LE" << false; + QTest::newRow("doc25") << "UTF-32" << false; + QTest::newRow("doc26") << "UTF-32BE" << false; + QTest::newRow("doc27") << "UTF-32LE" << false; + //Windows-1250 to 1258 tested previously + QTest::newRow("doc3") << "WINSAMI2" << false; } void tst_QTextCodec::fromUnicode() @@ -222,6 +268,7 @@ void tst_QTextCodec::fromUnicode() chars[i] = i + 128; QString s = codec->toUnicode(chars, 128); QByteArray c = codec->fromUnicode(s); + QCOMPARE(c.size(), 128); int numberOfQuestionMarks = 0; for (int i = 0; i < 128; ++i) { @@ -360,7 +407,7 @@ void tst_QTextCodec::asciiToIscii() const /* For each codec. */ const QTextCodec *const textCodec = QTextCodec::codecForName(isciiCodecs[i]); - Q_ASSERT(textCodec); + QVERIFY(textCodec); for(int i2 = 0; i2 < len; ++i2) { /* For each character in ascii. */ @@ -384,9 +431,12 @@ void tst_QTextCodec::flagCodepointFFFF() const Q_ASSERT(codec); const QByteArray asDecoded(codec->fromUnicode(input)); + QCOMPARE(asDecoded, QByteArray("?")); + + QByteArray ffff("\357\277\277"); QTextCodec::ConverterState state(QTextCodec::ConvertInvalidToNull); - QVERIFY(codec->toUnicode(asDecoded.constData(), asDecoded.length(), &state) == QChar(0)); - QVERIFY(codec->toUnicode(asDecoded) == QChar(0xfffd)); + QVERIFY(codec->toUnicode(ffff.constData(), ffff.length(), &state) == QChar(0)); + QVERIFY(codec->toUnicode(ffff) == QChar(0xfffd)); } void tst_QTextCodec::flagF7808080() const @@ -447,12 +497,11 @@ void tst_QTextCodec::flagEFBFBF() const /* When 0xEFBFBF is preceeded by what seems to be an arbitrary character, * QTextCodec fails to flag it. */ { - QEXPECT_FAIL("", "This is a bug and needs to be fixed.", Continue); QByteArray start("B"); start.append(invalidInput); QTextCodec::ConverterState state(QTextCodec::ConvertInvalidToNull); - QVERIFY(codec->toUnicode(start.constData(), start.length(), &state) == QChar(0)); + QVERIFY(codec->toUnicode(start.constData(), start.length(), &state) == QString::fromLatin1("B\0", 2)); } } @@ -478,7 +527,9 @@ void tst_QTextCodec::aliasForUTF16() const void tst_QTextCodec::mibForTSCII() const { - QCOMPARE(QTextCodec::codecForName("TSCII")->mibEnum(), 2107); + QTextCodec *codec = QTextCodec::codecForName("TSCII"); + QVERIFY(codec); + QCOMPARE(codec->mibEnum(), 2107); } static QString fromInvalidUtf8Sequence(const QByteArray &ba) @@ -695,15 +746,15 @@ void tst_QTextCodec::utf8Codec_data() str = QChar(QChar::ReplacementCharacter); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.3") << utf8 << str << -1; - // 2.3.4 U+0010FFFF + // 2.3.4 U+0010FFFD utf8.clear(); utf8 += char(0xf4); utf8 += char(0x8f); utf8 += char(0xbf); - utf8 += char(0xbf); + utf8 += char(0xbd); str.clear(); str += QChar(0xdbff); - str += QChar(0xdfff); + str += QChar(0xdffd); QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.4") << utf8 << str << -1; // 2.3.5 U+00110000 @@ -1938,17 +1989,210 @@ static int loadAndConvertMIB(int mib) void tst_QTextCodec::threadSafety() { + QList<QByteArray> codecList = QTextCodec::availableCodecs(); + QList<int> mibList = QTextCodec::availableMibs(); +#ifndef QT_NO_CONCURRENT QThreadPool::globalInstance()->setMaxThreadCount(12); - QList<QByteArray> codecList = QTextCodec::availableCodecs(); QFuture<QByteArray> res = QtConcurrent::mapped(codecList, loadAndConvert); - QList<int> mibList = QTextCodec::availableMibs(); + QFuture<int> res2 = QtConcurrent::mapped(mibList, loadAndConvertMIB); QCOMPARE(res.results(), codecList); QCOMPARE(res2.results(), mibList); +#endif +} + +void tst_QTextCodec::invalidNames() +{ + QVERIFY(!QTextCodec::codecForName("")); + QVERIFY(!QTextCodec::codecForName(QByteArray())); + QVERIFY(!QTextCodec::codecForName("-")); + QVERIFY(!QTextCodec::codecForName("\1a\2b\3a\4d\5c\6s\7a\xffr\xec_\x9c_")); + QVERIFY(!QTextCodec::codecForName("\n")); + QVERIFY(!QTextCodec::codecForName("don't exist")); + QByteArray huge = "azertyuiop^$qsdfghjklm<wxcvbn,;:=1234567890°_"; + huge = huge + huge + huge + huge + huge + huge + huge + huge; + huge = huge + huge + huge + huge + huge + huge + huge + huge; + huge = huge + huge + huge + huge + huge + huge + huge + huge; + huge = huge + huge + huge + huge + huge + huge + huge + huge; + QVERIFY(!QTextCodec::codecForName(huge)); +} + +void tst_QTextCodec::checkAliases_data() +{ + QTest::addColumn<QByteArray>("codecName"); + QList<QByteArray> codecList = QTextCodec::availableCodecs(); + foreach (const QByteArray &a, codecList) { + QTest::newRow( a.constData() ) << a; + } +} + +void tst_QTextCodec::checkAliases() +{ + QFETCH( QByteArray, codecName ); + QTextCodec *c = QTextCodec::codecForName(codecName); + QVERIFY(c); + QCOMPARE(QTextCodec::codecForName(codecName), c); + QCOMPARE(QTextCodec::codecForName(c->name()), c); + + foreach(const QByteArray &a, c->aliases()) { + QCOMPARE(QTextCodec::codecForName(a), c); + } +} + + +void tst_QTextCodec::moreToFromUnicode_data() { + QTest::addColumn<QByteArray>("codecName"); + QTest::addColumn<QByteArray>("testData"); + + QTest::newRow("russian") << QByteArray("ISO-8859-5") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF\x00"); + + QTest::newRow("arabic") << QByteArray("ISO-8859-6") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA4\xAC\xAD\xBB\xBF\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2"); + + QTest::newRow("greek") << QByteArray("ISO-8859-7") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA6\xA7\xA8\xA9\xAB\xAC\xAD\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE"); + + QTest::newRow("turkish") << QByteArray("ISO-8859-9") + << QByteArray("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + +#ifdef Q_OS_SYMBIAN + QTest::newRow("thai") << QByteArray("TIS-620") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB"); +#endif + + QTest::newRow("latin1") << QByteArray("ISO-8859-1") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + + QByteArray sms7bit_ba; + for (int i=1; i <= 0x7f; ++i) { + if (i!='\x1b') { + sms7bit_ba.append(i); + } + } +#ifdef Q_OS_SYMBIAN + QTest::newRow("sms7bit") << QByteArray("SMS 7-bit") << sms7bit_ba; +#endif + + QTest::newRow("latin2") << QByteArray("ISO-8859-2") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + + QTest::newRow("latin3") << QByteArray("ISO-8859-3") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBF\xC0\xC1\xC2\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + + QTest::newRow("latin4") << QByteArray("ISO-8859-4") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + + QTest::newRow("russian 2") << QByteArray("ISO-8859-5") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + + QTest::newRow("arabic 2") << QByteArray("ISO-8859-6") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA4\xAC\xAD\xBB\xBF\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2"); + + QTest::newRow("greek 2") << QByteArray("ISO-8859-7") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA6\xA7\xA8\xA9\xAB\xAC\xAD\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE"); + +#ifdef Q_OS_SYMBIAN + QTest::newRow("hebriew") << QByteArray("ISO-8859-8") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFD\xFE"); +#endif + + QTest::newRow("latin5") << QByteArray("ISO-8859-9") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + + QTest::newRow("latin6") << QByteArray("ISO-8859-10") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + +#if 0 + QByteArray iso8859_11_ba; + for (int x=0x20; x<=0x7f; ++x) { + iso8859_11_ba.append(x); + } + for (int x=0xa0; x<0xff; ++x) { + if ((x>=0xdb && x<0xdf) || x>0xfb){ + continue; + } + iso8859_11_ba.append(x); + } + QTest::newRow("latin-thai") << QByteArray("ISO-8859-11") << iso8859_11_ba; +#endif + + QTest::newRow("latin7") << QByteArray("ISO-8859-13") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + + QTest::newRow("celtic") << QByteArray("ISO-8859-14") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + + QTest::newRow("latin9") << QByteArray("ISO-8859-15") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + + QTest::newRow("latin10") << QByteArray("ISO-8859-16") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + + QTest::newRow("cp850") << QByteArray("CP850") + << QByteArray("\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"); + + QTest::newRow("cp874") << QByteArray("CP874") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x85\x91\x92\x93\x94\x95\x96\x97\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB"); + + QTest::newRow("cp1250") << QByteArray("CP1250") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x82\x84\x85\x86\x87\x89\x8A\x8B\x8C\x8D\x8E\x8F\x91\x92\x93\x94\x95\x96\x97\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + + QTest::newRow("cp1251") << QByteArray("CP1251") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + + QTest::newRow("cp1252") << QByteArray("CP1252") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8E\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + + QTest::newRow("cp1253") << QByteArray("CP1253") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x82\x83\x84\x85\x86\x87\x89\x8B\x91\x92\x93\x94\x95\x96\x97\x99\x9B\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE"); + + QTest::newRow("cp1254") << QByteArray("CP1254") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + + QTest::newRow("cp1255") << QByteArray("CP1255") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x82\x83\x84\x85\x86\x87\x88\x89,x8B\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9B\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFD\xFE"); + + QTest::newRow("cp1256") << QByteArray("CP1256") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + + QTest::newRow("cp1257") << QByteArray("CP1257") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x82\x84\x85\x86\x87\x89\x8B\x8D\x8E\x8F\x91\x92\x93\x94\x95\x96\x97\x99\x9B\x9D\x9E\xA0\xA2\xA3\xA4\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + + QTest::newRow("cp1258") << QByteArray("CP1258") + << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x82\x83\x84\x85\x86\x87\x88\x89\x8B\x8C\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9B\x9C\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF"); + + QByteArray koi8_r_ba; + for (int x=0x20; x<=0xff; ++x) { + if (x!=0x9A && x!=0xbf) { + koi8_r_ba.append(x); + } + } + QTest::newRow("KOI8-R") << QByteArray("KOI8-R") << koi8_r_ba; + + QByteArray koi8_u_ba; + for (int x=0x20; x<=0xff; ++x) { + koi8_u_ba.append(x); + } + QTest::newRow("KOI8-U") << QByteArray("KOI8-U") << koi8_u_ba; } +void tst_QTextCodec::moreToFromUnicode() +{ + QFETCH( QByteArray, codecName ); + QFETCH( QByteArray, testData ); + + QTextCodec *c = QTextCodec::codecForName( codecName.data() ); + QVERIFY(c); + + QString uStr = c->toUnicode(testData); + QByteArray cStr = c->fromUnicode(uStr); + QCOMPARE(testData, cStr); +} + + QTEST_MAIN(tst_QTextCodec) #include "tst_qtextcodec.moc" diff --git a/tests/auto/qtextstream/tst_qtextstream.cpp b/tests/auto/qtextstream/tst_qtextstream.cpp index 9146be2..4c78ef0 100644 --- a/tests/auto/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/qtextstream/tst_qtextstream.cpp @@ -221,6 +221,7 @@ private slots: void nanInf(); void utf8IncompleteAtBufferBoundary_data(); void utf8IncompleteAtBufferBoundary(); + void writeSeekWriteNoBOM(); // status void status_real_read_data(); @@ -1847,6 +1848,63 @@ void tst_QTextStream::utf8IncompleteAtBufferBoundary() } // ------------------------------------------------------------------------------ + +// Make sure we don't write a BOM after seek()ing + +void tst_QTextStream::writeSeekWriteNoBOM() +{ + + //First with the default codec (normally either latin-1 or UTF-8) + + QBuffer out; + out.open(QIODevice::WriteOnly); + QTextStream stream(&out); + + int number = 0; + QString sizeStr = QLatin1String("Size=") + + QString::number(number).rightJustified(10, QLatin1Char('0')); + stream << sizeStr << endl; + stream << "Version=" << QString::number(14) << endl; + stream << "blah blah blah" << endl; + stream.flush(); + + QCOMPARE(out.buffer().constData(), "Size=0000000000\nVersion=14\nblah blah blah\n"); + + // Now overwrite the size header item + number = 42; + stream.seek(0); + sizeStr = QLatin1String("Size=") + + QString::number(number).rightJustified(10, QLatin1Char('0')); + stream << sizeStr << endl; + stream.flush(); + + // Check buffer is still OK + QCOMPARE(out.buffer().constData(), "Size=0000000042\nVersion=14\nblah blah blah\n"); + + + //Then UTF-16 + + QBuffer out16; + out16.open(QIODevice::WriteOnly); + QTextStream stream16(&out16); + stream16.setCodec("UTF-16"); + + stream16 << "one" << "two" << QLatin1String("three"); + stream16.flush(); + + // save that output + QByteArray first = out16.buffer(); + + stream16.seek(0); + stream16 << "one"; + stream16.flush(); + + QCOMPARE(out16.buffer(), first); +} + + + +// ------------------------------------------------------------------------------ void tst_QTextStream::generateOperatorCharData(bool for_QString) { QTest::addColumn<QByteArray>("input"); diff --git a/tests/auto/qtimer/tst_qtimer.cpp b/tests/auto/qtimer/tst_qtimer.cpp index cc97e4e..a0408ef 100644 --- a/tests/auto/qtimer/tst_qtimer.cpp +++ b/tests/auto/qtimer/tst_qtimer.cpp @@ -85,6 +85,7 @@ private slots: void timerFiresOnlyOncePerProcessEvents(); void timerIdPersistsAfterThreadExit(); void cancelLongTimer(); + void singleShotStaticFunctionZeroTimeout(); }; class TimerHelper : public QObject @@ -611,5 +612,16 @@ void tst_QTimer::cancelLongTimer() QVERIFY(!timer.isActive()); } +void tst_QTimer::singleShotStaticFunctionZeroTimeout() +{ + TimerHelper helper; + + QTimer::singleShot(0, &helper, SLOT(timeout())); + QTest::qWait(500); + QCOMPARE(helper.count, 1); + QTest::qWait(500); + QCOMPARE(helper.count, 1); +} + QTEST_MAIN(tst_QTimer) #include "tst_qtimer.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/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 83109b5..b7cbdb8 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -193,6 +193,7 @@ private slots: void fromUserInput(); void task_199967(); void task_240612(); + void taskQTBUG_6962(); #ifdef QT3_SUPPORT void dirPath(); @@ -3860,5 +3861,13 @@ void tst_QUrl::resolvedWithAbsoluteSchemes_data() const << QUrl::fromEncoded("http://www.foo.com:8080/newfile.html"); } +void tst_QUrl::taskQTBUG_6962() +{ + //bug 6962: empty authority ignored by setAuthority + QUrl url("http://example.com/something"); + url.setAuthority(QString()); + QCOMPARE(url.authority(), QString()); +} + QTEST_MAIN(tst_QUrl) #include "tst_qurl.moc" 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/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/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P02/ibm02v01.xml b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P02/ibm02v01.xml index 60479f4..2363b97 100644 --- a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P02/ibm02v01.xml +++ b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P02/ibm02v01.xml @@ -5,6 +5,6 @@ discrete legal characters for production 02. -->
<?NAME_09- _0A-
_0D-
-_20- _D7FF-퟿_6c0f-æ°_E000-_FFFD-�_effe-_010000-ð€€_10FFFF-ô¿¿_08ffff-ò¿¿ This is a PI target ?>
+_20- _D7FF-퟿_6c0f-æ°_E000-_FFFD-�_effd-_010000-ð€€_10FFFD-ô¿½_08fffd-ò¿½ This is a PI target ?>
]>
<book/>
diff --git a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/ibm66v01.xml b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/ibm66v01.xml index 7ac675e..d7f7722 100644 --- a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/ibm66v01.xml +++ b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/ibm66v01.xml @@ -11,6 +11,6 @@ Test all valid Charater references for P66: C C _
  힣 가
豈 �
-𐀀 
+𐀀 􏿽
</root>
<!--* a valid test for P66 *-->
diff --git a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/out/ibm66v01.xml b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/out/ibm66v01.xml index 1b04b6d..ed05e61 100644 --- a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/out/ibm66v01.xml +++ b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/ibm/valid/P66/out/ibm66v01.xml @@ -1 +1 @@ -<root> Test all valid Charater references for P66: 			 « « à à ï ï C C _ 힣 ê°€ 豈 � ð€€ ô¿¿ </root>
\ No newline at end of file +<root> Test all valid Charater references for P66: 			 « « à à ï ï C C _ 힣 ê°€ 豈 � ð€€ ô¿½ </root>
\ No newline at end of file diff --git a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/089.xml b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/089.xml index 2d80c8f..42ffcb6 100644 --- a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/089.xml +++ b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/089.xml @@ -1,5 +1,5 @@ <!DOCTYPE doc [
-<!ENTITY e "𐀀􏿽">
+<!ENTITY e "𐀀􏿽">
<!ELEMENT doc (#PCDATA)>
]>
<doc>&e;</doc>
diff --git a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/out/089.xml b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/out/089.xml index e01d86e..f5a0484 100644 --- a/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/out/089.xml +++ b/tests/auto/qxmlstream/XML-Test-Suite/xmlconf/xmltest/valid/sa/out/089.xml @@ -1 +1 @@ -<doc>ð€€ô¿½ô¿¿</doc>
\ No newline at end of file +<doc>ð€€ô¿½</doc>
\ No newline at end of file diff --git a/tests/auto/utf8/tst_utf8.cpp b/tests/auto/utf8/tst_utf8.cpp index 1183b81..7bbbfab 100644 --- a/tests/auto/utf8/tst_utf8.cpp +++ b/tests/auto/utf8/tst_utf8.cpp @@ -73,6 +73,9 @@ private slots: void invalidUtf8_data(); void invalidUtf8(); + + void nonCharacters_data(); + void nonCharacters(); }; void tst_Utf8::initTestCase() @@ -134,8 +137,8 @@ void tst_Utf8::roundTrip_data() static const uint utf32_5[] = { 0x010203 }; QTest::newRow("utf8_5") << QByteArray(utf8_5) << QString::fromUcs4(utf32_5, 1); - static const char utf8_6[] = "\364\217\277\277"; // U+10FFFF - static const uint utf32_6[] = { 0x10FFFF }; + static const char utf8_6[] = "\364\217\277\275"; // U+10FFFD + static const uint utf32_6[] = { 0x10FFFD }; QTest::newRow("utf8_6") << QByteArray(utf8_6) << QString::fromUcs4(utf32_6, 1); static const char utf8_7[] = "abc\302\240\303\241\303\251\307\275 \342\202\254def"; @@ -144,10 +147,10 @@ void tst_Utf8::roundTrip_data() ' ', 0x20AC, 'd', 'e', 'f', 0 }; QTest::newRow("utf8_7") << QByteArray(utf8_7) << QString::fromUtf16(utf16_7); - static const char utf8_8[] = "abc\302\240\303\241\303\251\307\275 \364\217\277\277 \342\202\254def"; + static const char utf8_8[] = "abc\302\240\303\241\303\251\307\275 \364\217\277\275 \342\202\254def"; static const uint utf32_8[] = { 'a', 'b', 'c', 0x00A0, 0x00E1, 0x00E9, 0x01FD, - ' ', 0x10FFFF, ' ', + ' ', 0x10FFFD, ' ', 0x20AC, 'd', 'e', 'f', 0 }; QTest::newRow("utf8_8") << QByteArray(utf8_8) << QString::fromUcs4(utf32_8); } @@ -214,14 +217,6 @@ void tst_Utf8::invalidUtf8_data() QTest::newRow("4chars-2") << QByteArray("\xF0\x90\xC0\x80"); QTest::newRow("4chars-3") << QByteArray("\xF0\xC0\x80\x80"); - // U+FFFE and U+FFFF are non-characters and must not be present - // U+FFFE: 1111 11 1111 11 1110 - // encoding: xxxz:1111 xz11:1111 xz11:1110 - QTest::newRow("fffe") << QByteArray("\xEF\xBF\xBE"); - // U+FFFF: 1111 11 1111 11 1111 - // encoding: xxxz:1111 xz11:1111 xz11:1111 - QTest::newRow("ffff") << QByteArray("\xEF\xBF\xBF"); - // Surrogate pairs must now be present either // U+D800: 1101 10 0000 00 0000 // encoding: xxxz:1101 xz10:0000 xz00:0000 @@ -302,7 +297,7 @@ void tst_Utf8::invalidUtf8() QFETCH_GLOBAL(bool, useLocale); QSharedPointer<QTextDecoder> decoder = QSharedPointer<QTextDecoder>(codec->makeDecoder()); - QString decoded = decoder->toUnicode(utf8); + decoder->toUnicode(utf8); // Only enforce correctness on our UTF-8 decoder // The system's UTF-8 codec is sometimes buggy @@ -314,5 +309,69 @@ void tst_Utf8::invalidUtf8() qWarning("System codec does not report failure when it should. Should report bug upstream."); } +void tst_Utf8::nonCharacters_data() +{ + QTest::addColumn<QByteArray>("utf8"); + QTest::addColumn<QString>("utf16"); + + // Unicode has a couple of "non-characters" that one can use internally, + // but are not allowed to be used for text interchange. + // + // Those are the last two entries each Unicode Plane (U+FFFE, U+FFFF, + // U+1FFFE, U+1FFFF, etc.) as well as the entries between U+FDD0 and + // U+FDEF (inclusive) + + // U+FDD0 through U+FDEF + for (int i = 0; i < 16; ++i) { + char utf8[] = { 0357, 0267, 0220 + i, 0 }; + QString utf16 = QChar(0xfdd0 + i); + QTest::newRow(qPrintable(QString::number(0xfdd0 + i, 16))) << QByteArray(utf8) << utf16; + } + + // the last two in Planes 1 through 16 + for (uint plane = 1; plane <= 16; ++plane) { + for (uint lower = 0xfffe; lower < 0x10000; ++lower) { + uint ucs4 = (plane << 16) | lower; + char utf8[] = { 0xf0 | uchar(ucs4 >> 18), + 0x80 | (uchar(ucs4 >> 12) & 0x3f), + 0x80 | (uchar(ucs4 >> 6) & 0x3f), + 0x80 | (uchar(ucs4) & 0x3f), + 0 }; + ushort utf16[] = { QChar::highSurrogate(ucs4), QChar::lowSurrogate(ucs4), 0 }; + + QTest::newRow(qPrintable(QString::number(ucs4, 16))) << QByteArray(utf8) << QString::fromUtf16(utf16); + } + } + + QTest::newRow("fffe") << QByteArray("\xEF\xBF\xBE") << QString(QChar(0xfffe)); + QTest::newRow("ffff") << QByteArray("\xEF\xBF\xBF") << QString(QChar(0xffff)); +} + +void tst_Utf8::nonCharacters() +{ + QFETCH(QByteArray, utf8); + QFETCH(QString, utf16); + QFETCH_GLOBAL(bool, useLocale); + + QSharedPointer<QTextDecoder> decoder = QSharedPointer<QTextDecoder>(codec->makeDecoder()); + decoder->toUnicode(utf8); + + // Only enforce correctness on our UTF-8 decoder + // The system's UTF-8 codec is sometimes buggy + // GNU libc's iconv is known to accept U+FFFF and U+FFFE encoded as UTF-8 + // OS X's iconv is known to accept those, plus surrogates and codepoints above U+10FFFF + if (!useLocale) + QVERIFY(decoder->hasFailure()); + else if (!decoder->hasFailure()) + qWarning("System codec does not report failure when it should. Should report bug upstream."); + + QSharedPointer<QTextEncoder> encoder(codec->makeEncoder()); + encoder->fromUnicode(utf16); + if (!useLocale) + QVERIFY(encoder->hasFailure()); + else if (!encoder->hasFailure()) + qWarning("System codec does not report failure when it should. Should report bug upstream."); +} + QTEST_MAIN(tst_Utf8) #include "tst_utf8.moc" 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/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro new file mode 100644 index 0000000..9c6b16b --- /dev/null +++ b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/qtimer_vs_qmetaobject.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = qtimer_vs_qmetaobject +DEPENDPATH += . +INCLUDEPATH += . + +CONFIG += release +#CONFIG += debug + + +SOURCES += tst_qtimer_vs_qmetaobject.cpp diff --git a/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp new file mode 100644 index 0000000..2f265bf --- /dev/null +++ b/tests/benchmarks/corelib/kernel/qtimer_vs_qmetaobject/tst_qtimer_vs_qmetaobject.cpp @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** 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 <QtCore> +#include <QtTest/QtTest> + +#define INVOKE_COUNT 10000 + +class qtimer_vs_qmetaobject : public QObject +{ + Q_OBJECT +private slots: + void testZeroTimerSingleShot(); + void testQueuedInvokeMethod(); +}; + +class InvokeCounter : public QObject { + Q_OBJECT +public: + InvokeCounter() : count(0) { }; +public slots: + void invokeSlot() { + count++; + if (count == INVOKE_COUNT) + QTestEventLoop::instance().exitLoop(); + } +protected: + int count; +}; + +void qtimer_vs_qmetaobject::testZeroTimerSingleShot() +{ + QBENCHMARK { + InvokeCounter invokeCounter; + for(int i = 0; i < INVOKE_COUNT; ++i) { + QTimer::singleShot(0, &invokeCounter, SLOT(invokeSlot())); + } + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + } +} + +void qtimer_vs_qmetaobject::testQueuedInvokeMethod() +{ + QBENCHMARK { + InvokeCounter invokeCounter; + for(int i = 0; i < INVOKE_COUNT; ++i) { + QMetaObject::invokeMethod(&invokeCounter, "invokeSlot", Qt::QueuedConnection); + } + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + } +} + + +QTEST_MAIN(qtimer_vs_qmetaobject) + +#include "tst_qtimer_vs_qmetaobject.moc" 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/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp index 5b0004f..cd69cfe 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 @@ -67,6 +68,8 @@ private slots: void qobject_qmltype(); void qobject_alloc(); + void qdeclarativecontext(); + void objects_qmltype_data(); void objects_qmltype(); @@ -101,7 +104,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; @@ -150,6 +154,14 @@ void tst_creation::qobject_alloc() } } +void tst_creation::qdeclarativecontext() +{ + QBENCHMARK { + QDeclarativeContext *ctxt = new QDeclarativeContext(&engine); + delete ctxt; + } +} + void tst_creation::objects_qmltype_data() { QTest::addColumn<QByteArray>("type"); 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/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/painting.pro b/tests/benchmarks/gui/painting/painting.pro index 2c042b5..76c26c1 100644 --- a/tests/benchmarks/gui/painting/painting.pro +++ b/tests/benchmarks/gui/painting/painting.pro @@ -3,4 +3,5 @@ SUBDIRS = \ qpainter \ qregion \ qtransform \ - qtracebench + qtracebench \ + qtbench 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/qtbench/benchmarktests.h b/tests/benchmarks/gui/painting/qtbench/benchmarktests.h new file mode 100644 index 0000000..362d121 --- /dev/null +++ b/tests/benchmarks/gui/painting/qtbench/benchmarktests.h @@ -0,0 +1,841 @@ +/**************************************************************************** +** +** 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 FOO module 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$ +** +****************************************************************************/ + +#ifndef BENCHMARKTESTS_H +#define BENCHMARKTESTS_H + +#include <QApplication> +#include <QTextDocument> +#include <QDesktopWidget> +#include <QTextLayout> +#include <QFontMetrics> +#include <QDebug> + +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) +# include <QStaticText> +#endif + +class Benchmark +{ +public: + virtual ~Benchmark() {} + + Benchmark(const QSize &size) + : m_size(size) + { + for (int i=0; i<16; ++i) { + m_colors[i] = QColor::fromRgbF((rand() % 4) / 3.0, + (rand() % 4) / 3.0, + (rand() % 4) / 3.0, + 1); + } + } + + virtual void draw(QPainter *p, const QRect &rect, int iteration) = 0; + virtual QString name() const = 0; + + inline const QSize &size() const + { + return m_size; + } + virtual void begin(QPainter *, int iterations = 1) { Q_UNUSED(iterations); } + virtual void end(QPainter *) { } + + inline const QColor &randomColor(int i) { return m_colors[i % 16]; } + +protected: + QColor m_colors[16]; + QSize m_size; +}; + +class PaintingRectAdjuster +{ +public: + PaintingRectAdjuster() + : m_benchmark(0), + m_bounds(), + m_screen_filled(false) + { + } + + const QRect &newPaintingRect() { + m_rect.translate(m_rect.width(), 0); + + if (m_rect.right() > m_bounds.width()) { + m_rect.moveLeft(m_bounds.left()); + m_rect.translate(0,m_rect.height()); + if (m_rect.bottom() > m_bounds.height()) { + m_screen_filled = true; + m_rect.moveTo(m_bounds.topLeft()); + } + } + return m_rect; + } + + inline bool isScreenFilled() const + { return m_screen_filled; } + + void reset(const QRect &bounds) + { + m_bounds = bounds; + m_rect.moveTo(m_bounds.topLeft()); + m_rect = QRect(m_bounds.topLeft(),m_benchmark->size()); + m_rect.translate(-m_rect.width(),0); + m_screen_filled = false; + } + + inline void setNewBenchmark( Benchmark *benchmark ) + { + m_benchmark = benchmark; + } + +protected: + Benchmark *m_benchmark; + QRect m_rect; + QRect m_bounds; + bool m_screen_filled; +}; + +class FillRectBenchmark : public Benchmark +{ +public: + FillRectBenchmark(int size) + : Benchmark(QSize(size, size)) + { + } + + virtual void draw(QPainter *p, const QRect &rect, int iterationCount) { + p->fillRect(rect, randomColor(iterationCount)); + } + + virtual QString name() const { + return QString::fromLatin1("fillRect(%1)").arg(m_size.width()); + } +}; + +class ImageFillRectBenchmark : public Benchmark +{ +public: + ImageFillRectBenchmark(int size) + : Benchmark(QSize(size, size)) + { + int s = rand() % 24 + 8; + m_content = QImage(s, s, QImage::Format_ARGB32_Premultiplied); + QPainter p(&m_content); + p.fillRect(0, 0, s, s, Qt::white); + p.fillRect(s/2, 0, s/2, s/2, Qt::gray); + p.fillRect(0, s/2, s/2, s/2, Qt::gray); + p.end(); + + m_brush = QBrush(m_content); + } + + virtual void draw(QPainter *p, const QRect &rect, int) { + p->fillRect(rect, m_brush); + } + + virtual QString name() const { + return QString::fromLatin1("fillRect with image(%1)").arg(m_size.width()); + } + +private: + QImage m_content; + QBrush m_brush; +}; + + +class DrawRectBenchmark : public Benchmark +{ +public: + DrawRectBenchmark(int size) + : Benchmark(QSize(size, size)) + { + } + + virtual void begin(QPainter *p, int) { + p->setPen(Qt::NoPen); + p->setBrush(randomColor(m_size.width())); + } + + + virtual void draw(QPainter *p, const QRect &rect, int) { + p->drawRect(rect); + } + + virtual QString name() const { + return QString::fromLatin1("drawRect(%1)").arg(m_size.width()); + } +}; + + +class DrawRectWithBrushChangeBenchmark : public Benchmark +{ +public: + DrawRectWithBrushChangeBenchmark(int size) + : Benchmark(QSize(size, size)) + { + } + + virtual void begin(QPainter *p, int) { + p->setPen(Qt::NoPen); + } + + + virtual void draw(QPainter *p, const QRect &rect, int i) { + p->setBrush(randomColor(i)); + p->drawRect(rect); + } + + virtual QString name() const { + return QString::fromLatin1("drawRect with brushchange(%1)").arg(m_size.width()); + } +}; + +class RoundRectBenchmark : public Benchmark +{ +public: + RoundRectBenchmark(int size) + : Benchmark(QSize(size, size)) + { + m_roundness = size / 4.; + } + + virtual void begin(QPainter *p, int) { + p->setPen(Qt::NoPen); + p->setBrush(Qt::red); + } + + virtual void draw(QPainter *p, const QRect &rect, int) { + p->drawRoundedRect(rect, m_roundness, m_roundness); + } + + virtual QString name() const { + return QString::fromLatin1("drawRoundedRect(%1)").arg(m_size.width()); + } + + qreal m_roundness; +}; + + +class ArcsBenchmark : public Benchmark +{ +public: + enum Type { + Stroked = 0x0001, + Filled = 0x0002, + + ArcShape = 0x0010, + ChordShape = 0x0020, + PieShape = 0x0040, + CircleShape = 0x0080, + Shapes = 0x00f0 + + }; + + ArcsBenchmark(int size, uint type) + : Benchmark(QSize(size, size)), + m_type(type) + { + } + + virtual void begin(QPainter *p, int) { + if (m_type & Stroked) + p->setPen(Qt::black); + else + p->setPen(Qt::NoPen); + + if (m_type & Filled) + p->setBrush(Qt::red); + else + p->setBrush(Qt::NoBrush); + } + + virtual void draw(QPainter *p, const QRect &rect, int) { + switch (m_type & Shapes) { + case ArcShape: + p->drawArc(rect, 45*16, 120*16); + break; + case ChordShape: + p->drawChord(rect, 45*16, 120*16); + break; + case PieShape: + p->drawPie(rect, 45*16, 120*16); + break; + case CircleShape: + p->drawEllipse(rect); + break; + } + } + + virtual QString name() const { + QString fillStroke; + + if ((m_type & (Stroked|Filled)) == (Stroked|Filled)) { + fillStroke = QLatin1String("Fill & Outline"); + } else if (m_type & Stroked) { + fillStroke = QLatin1String("Outline"); + } else if (m_type & Filled) { + fillStroke = QLatin1String("Fill"); + } + + QString shape; + if (m_type & PieShape) shape = QLatin1String("drawPie"); + else if (m_type & ChordShape) shape = QLatin1String("drawChord"); + else if (m_type & ArcShape) shape = QLatin1String("drawArc"); + else if (m_type & CircleShape) shape = QLatin1String("drawEllipse"); + + return QString::fromLatin1("%1(%2) %3").arg(shape).arg(m_size.width()).arg(fillStroke); + } + + uint m_type; +}; + + +class DrawScaledImage : public Benchmark +{ +public: + DrawScaledImage(const QImage &image, qreal scale, bool asPixmap) + : Benchmark(QSize(image.width(), image.height())), + m_image(image), + m_type(m_as_pixmap ? "Pixmap" : "Image"), + m_scale(scale), + m_as_pixmap(asPixmap) + { + m_pixmap = QPixmap::fromImage(m_image); + } + DrawScaledImage(const QString& type, const QPixmap &pixmap, qreal scale) + : Benchmark(QSize(pixmap.width(), pixmap.height())), + m_type(type), + m_scale(scale), + m_as_pixmap(true), + m_pixmap(pixmap) + { + } + + virtual void begin(QPainter *p, int) { + p->scale(m_scale, m_scale); + } + + virtual void draw(QPainter *p, const QRect &rect, int) { + if (m_as_pixmap) + p->drawPixmap(rect.topLeft(), m_pixmap); + else + p->drawImage(rect.topLeft(), m_image); + } + + virtual QString name() const { + return QString::fromLatin1("draw%4(%1) at scale=%2, depth=%3") + .arg(m_size.width()) + .arg(m_scale) + .arg(m_as_pixmap ? m_pixmap.depth() : m_image.depth()) + .arg(m_type); + } + +private: + QImage m_image; + QString m_type; + qreal m_scale; + bool m_as_pixmap; + QPixmap m_pixmap; +}; + +class DrawTransformedImage : public Benchmark +{ +public: + DrawTransformedImage(const QImage &image, bool asPixmap) + : Benchmark(QSize(image.width(), image.height())), + m_image(image), + m_type(m_as_pixmap ? "Pixmap" : "Image"), + m_as_pixmap(asPixmap) + { + m_pixmap = QPixmap::fromImage(m_image); + } + DrawTransformedImage(const QString& type, const QPixmap &pixmap) + : Benchmark(QSize(pixmap.width(), pixmap.height())), + m_type(type), + m_as_pixmap(true), + m_pixmap(pixmap) + { + } + + virtual void draw(QPainter *p, const QRect &rect, int) { + QTransform oldTransform = p->transform(); + p->translate(0.5 * rect.width() + rect.left(), 0.5 * rect.height() + rect.top()); + p->shear(0.25, 0.0); + p->rotate(5.0); + if (m_as_pixmap) + p->drawPixmap(-0.5 * rect.width(), -0.5 * rect.height(), m_pixmap); + else + p->drawImage(-0.5 * rect.width(), -0.5 * rect.height(), m_image); + p->setTransform(oldTransform); + } + + virtual QString name() const { + return QString::fromLatin1("draw%3(%1) w/transform, depth=%2") + .arg(m_size.width()) + .arg(m_as_pixmap ? m_pixmap.depth() : m_image.depth()) + .arg(m_type); + } + +private: + QImage m_image; + QString m_type; + bool m_as_pixmap; + QPixmap m_pixmap; +}; + + +class DrawImage : public Benchmark +{ +public: + DrawImage(const QImage &image, bool asPixmap) + : Benchmark(QSize(image.width(), image.height())), + m_image(image), + m_type(m_as_pixmap ? "Pixmap" : "Image"), + m_as_pixmap(asPixmap) + { + m_pixmap = QPixmap::fromImage(image); + } + DrawImage(const QString& type, const QPixmap &pixmap) + : Benchmark(QSize(pixmap.width(), pixmap.height())), + m_type(type), + m_as_pixmap(true), + m_pixmap(pixmap) + { + } + + virtual void draw(QPainter *p, const QRect &rect, int) { + if (m_as_pixmap) + p->drawPixmap(rect.topLeft(), m_pixmap); + else + p->drawImage(rect.topLeft(), m_image); + } + + virtual QString name() const { + return QString::fromLatin1("draw%2(%1), depth=%3") + .arg(m_size.width()) + .arg(m_type) + .arg(m_as_pixmap ? m_pixmap.depth() : m_image.depth()); + } + +private: + QImage m_image; + QString m_type; + bool m_as_pixmap; + QPixmap m_pixmap; +}; + + +class DrawText : public Benchmark +{ +public: + enum Mode { + PainterMode, + PainterQPointMode, + LayoutMode, + DocumentMode, + PixmapMode + +#if QT_VERSION >= 0x040700 + , StaticTextMode, + StaticTextWithMaximumSizeMode, + StaticTextBackendOptimizations +#endif + }; + + DrawText(const QString &text, Mode mode) + : Benchmark(QSize()), m_mode(mode), m_text(text), m_document(text), m_layout(text) + { + } + + virtual void begin(QPainter *p, int iterations) { +#if QT_VERSION >= 0x040700 + m_staticTexts.clear(); + m_currentStaticText = 0; +#else + Q_UNUSED(iterations); +#endif + m_pixmaps.clear(); + m_currentPixmap = 0; + QRect m_bounds = QRect(0,0,p->device()->width(), p->device()->height()); + switch (m_mode) { + case PainterMode: + m_size = (p->boundingRect(m_bounds, 0, m_text)).size(); +// m_rect = m_rect.translated(-m_rect.topLeft()); + break; + case DocumentMode: + m_size = QSize(m_document.size().toSize()); + break; + case PixmapMode: + for (int i=0; i<4; ++i) { + m_size = (p->boundingRect(m_bounds, 0, m_text)).size(); + QPixmap pixmap = QPixmap(m_size); + pixmap.fill(Qt::transparent); + { + QPainter p(&pixmap); + p.drawText(pixmap.rect(), m_text); + } + m_pixmaps.append(pixmap); + } + break; + + case LayoutMode: { + QRect r = p->boundingRect(m_bounds, 0, m_text); + QStringList lines = m_text.split('\n'); + int height = 0; + int leading = p->fontMetrics().leading(); + m_layout.beginLayout(); + for (int i=0; i<lines.size(); ++i) { + QTextLine textLine = m_layout.createLine(); + if (textLine.isValid()) { + textLine.setLineWidth(r.width()); + textLine.setPosition(QPointF(0, height)); + height += leading + textLine.height(); + } + } + m_layout.endLayout(); + m_layout.setCacheEnabled(true); + m_size = m_layout.boundingRect().toRect().size(); + break; } + +#if QT_VERSION >= 0x040700 + case StaticTextWithMaximumSizeMode: { + QStaticText staticText; + m_size = (p->boundingRect(m_bounds, 0, m_text)).size(); + staticText.setMaximumSize(m_size + QSize(10, 10)); + staticText.setText(m_text); + staticText.prepare(p->transform(), p->font()); + m_staticTexts.append(staticText); + break; + } + case StaticTextBackendOptimizations: { + m_size = (p->boundingRect(m_bounds, 0, m_text)).size(); + for (int i=0; i<iterations; ++i) { + QStaticText staticText; + staticText.setPerformanceHint(QStaticText::AggressiveCaching); + staticText.setMaximumSize(m_size + QSize(10, 10)); + staticText.setText(m_text); + staticText.prepare(p->transform(), p->font()); + m_staticTexts.append(staticText); + } + + break; + } + case StaticTextMode: { + QStaticText staticText; + staticText.setText(m_text); + staticText.prepare(p->transform(), p->font()); + m_staticTexts.append(staticText); + + QFontMetrics fm(p->font()); + m_size = QSize(fm.width(m_text, m_text.length()), fm.height()); + + break; + } +#endif + + case PainterQPointMode: { + QFontMetrics fm(p->font()); + m_size = QSize(fm.width(m_text, m_text.length()), fm.height()); + break; + } + + } + } + + virtual void draw(QPainter *p, const QRect &rect, int) + { + switch (m_mode) { + case PainterMode: + p->drawText(rect, 0, m_text); + break; + case PainterQPointMode: + p->drawText(rect.topLeft(), m_text); + break; + case PixmapMode: + p->drawPixmap(rect.topLeft(), m_pixmaps.at(m_currentPixmap)); + m_currentPixmap = (m_currentPixmap + 1) % m_pixmaps.size(); + break; + case DocumentMode: + p->translate(rect.topLeft()); + m_document.drawContents(p); + p->translate(-rect.topLeft()); + break; + case LayoutMode: + m_layout.draw(p, rect.topLeft()); + break; + +#if QT_VERSION >= 0x040700 + case StaticTextWithMaximumSizeMode: + case StaticTextMode: + p->drawStaticText(rect.topLeft(), m_staticTexts.at(0)); + break; + case StaticTextBackendOptimizations: + p->drawStaticText(rect.topLeft(), m_staticTexts.at(m_currentStaticText)); + m_currentStaticText = (m_currentStaticText + 1) % m_staticTexts.size(); + break; +#endif + } + } + + virtual QString name() const { + int letters = m_text.length(); + int lines = m_text.count('\n'); + if (lines == 0) + lines = 1; + QString type; + switch (m_mode) { + case PainterMode: type = "drawText(rect)"; break; + case PainterQPointMode: type = "drawText(point)"; break; + case LayoutMode: type = "layout.draw()"; break; + case DocumentMode: type = "doc.drawContents()"; break; + case PixmapMode: type = "pixmap cached text"; break; + +#if QT_VERSION >= 0x040700 + case StaticTextMode: type = "drawStaticText()"; break; + case StaticTextWithMaximumSizeMode: type = "drawStaticText() w/ maxsize"; break; + case StaticTextBackendOptimizations: type = "drawStaticText() w/ backend optimizations"; break; +#endif + } + + return QString::fromLatin1("%3, len=%1, lines=%2") + .arg(letters) + .arg(lines) + .arg(type); + } + +private: + Mode m_mode; + QString m_text; + QTextDocument m_document; + QTextLayout m_layout; + + QList<QPixmap> m_pixmaps; + int m_currentPixmap; + +#if QT_VERSION >= 0x040700 + int m_currentStaticText; + QList<QStaticText> m_staticTexts; +#endif +}; + + + + +class ClippedDrawRectBenchmark : public Benchmark +{ +public: + enum ClipType { + RectClip, + TwoRectRegionClip, + EllipseRegionClip, + TwoRectPathClip, + EllipsePathClip, + AAEllipsePathClip, + EllipseRegionThenRectClip, + EllipsePathThenRectClip + }; + + ClippedDrawRectBenchmark(int size, ClipType type) + : Benchmark(QSize(size, size)), m_type(type) + { + } + + virtual void begin(QPainter *p, int) { + QRect m_bounds = QRect(0,0,p->device()->width(), p->device()->height()); + p->setPen(Qt::NoPen); + p->setBrush(Qt::red); + + switch (m_type) { + case RectClip: + p->setClipRect(m_bounds.adjusted(1, 1, -1, -1)); + break; + case TwoRectRegionClip: + p->setClipRegion(QRegion(m_bounds.adjusted(0, 0, -1, -1)) + | QRegion(m_bounds.adjusted(1, 1, 0, 0))); + break; + case EllipseRegionClip: + p->setClipRegion(QRegion(m_bounds, QRegion::Ellipse)); + break; + case TwoRectPathClip: + { + QPainterPath path; + path.addRect(m_bounds.adjusted(0, 0, -1, -1)); + path.addRect(m_bounds.adjusted(1, 1, 0, 0)); + path.setFillRule(Qt::WindingFill); + p->setClipPath(path); + } + break; + case EllipsePathClip: + { + QPainterPath path; + path.addEllipse(m_bounds); + p->setClipPath(path); + } + break; + case AAEllipsePathClip: + { + QPainterPath path; + path.addEllipse(m_bounds); + p->setRenderHint(QPainter::Antialiasing); + p->setClipPath(path); + p->setRenderHint(QPainter::Antialiasing, false); + } + break; + case EllipseRegionThenRectClip: + p->setClipRegion(QRegion(m_bounds, QRegion::Ellipse)); + p->setClipRegion(QRegion(m_bounds.width() / 4, + m_bounds.height() / 4, + m_bounds.width() / 2, + m_bounds.height() / 2), Qt::IntersectClip); + break; + case EllipsePathThenRectClip: + { + QPainterPath path; + path.addEllipse(m_bounds); + p->setClipPath(path); + p->setClipRegion(QRegion(m_bounds.width() / 4, + m_bounds.height() / 4, + m_bounds.width() / 2, + m_bounds.height() / 2), Qt::IntersectClip); + } + break; + } + } + + virtual void draw(QPainter *p, const QRect &rect, int) { + p->drawRect(rect); + } + + virtual QString name() const { + QString namedType; + switch (m_type) { + case RectClip: + namedType = "rect"; + break; + case TwoRectRegionClip: + namedType = "two-rect-region"; + break; + case EllipseRegionClip: + namedType = "ellipse-region"; + break; + case TwoRectPathClip: + namedType = "two-rect-path"; + break; + case EllipsePathClip: + namedType = "ellipse-path"; + break; + case AAEllipsePathClip: + namedType = "aa-ellipse-path"; + break; + case EllipseRegionThenRectClip: + namedType = "ellipseregion&rect"; + break; + case EllipsePathThenRectClip: + namedType = "ellipsepath&rect"; + break; + } + return QString::fromLatin1("%1-clipped-drawRect(%2)").arg(namedType).arg(m_size.width()); + } + + ClipType m_type; +}; + +class LinesBenchmark : public Benchmark +{ +public: + enum LineType { + Horizontal_Integer, + Diagonal_Integer, + Vertical_Integer, + Horizontal_Float, + Diagonal_Float, + Vertical_Float + }; + + LinesBenchmark(int length, LineType type) + : Benchmark(QSize(qAbs(length), qAbs(length))), + m_type(type), + m_length(length) + { + + } + + virtual void draw(QPainter *p, const QRect &rect, int) { + switch (m_type) { + case Horizontal_Integer: + p->drawLine(QLine(rect.x(), rect.y(), rect.x() + m_length, rect.y())); + break; + case Diagonal_Integer: + p->drawLine(QLine(rect.x(), rect.y(), rect.x() + m_length, rect.y() + m_length)); + break; + case Vertical_Integer: + p->drawLine(QLine(rect.x() + 4, rect.y(), rect.x() + 4, rect.y() + m_length)); + break; + case Horizontal_Float: + p->drawLine(QLineF(rect.x(), rect.y(), rect.x() + m_length, rect.y())); + break; + case Diagonal_Float: + p->drawLine(QLineF(rect.x(), rect.y(), rect.x() + m_length, rect.y() + m_length)); + break; + case Vertical_Float: + p->drawLine(QLineF(rect.x() + 4, rect.y(), rect.x() + 4, rect.y() + m_length)); + break; + } + } + + virtual QString name() const { + const char *names[] = { + "Hor_I", + "Diag_I", + "Ver_I", + "Hor_F", + "Diag_F", + "Ver_F" + }; + return QString::fromLatin1("drawLine(size=%1,type=%2)").arg(m_length).arg(names[m_type]); + } + + LineType m_type; + int m_length; +}; + +#endif // BENCHMARKTESTS_H diff --git a/tests/benchmarks/gui/painting/qtbench/qtbench.pro b/tests/benchmarks/gui/painting/qtbench/qtbench.pro new file mode 100644 index 0000000..91f416d --- /dev/null +++ b/tests/benchmarks/gui/painting/qtbench/qtbench.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qtbench + +SOURCES += tst_qtbench.cpp + diff --git a/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp b/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp new file mode 100644 index 0000000..8eef472 --- /dev/null +++ b/tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp @@ -0,0 +1,254 @@ +/**************************************************************************** +** +** 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 <QtGui> + +#include "benchmarktests.h" + +//TESTED_FILES= + +class BenchWidget : public QWidget +{ +public: + BenchWidget(Benchmark *benchmark); + + void paintEvent(QPaintEvent *event); + + bool done() const { return m_done; } + qreal result() const { return m_result; } + +public: + QTime timer; + + Benchmark *m_benchmark; + + bool m_done; + qreal m_result; + + uint m_total; + uint m_iteration; + + QVector<uint> iterationTimes; +}; + +void BenchWidget::paintEvent(QPaintEvent *) +{ + if (m_done) + return; + + QPainter p(this); + + m_benchmark->begin(&p, 100); + + PaintingRectAdjuster adjuster; + adjuster.setNewBenchmark(m_benchmark); + adjuster.reset(rect()); + + for (int i = 0; i < 100; ++i) + m_benchmark->draw(&p, adjuster.newPaintingRect(), i); + + m_benchmark->end(&p); + + ++m_iteration; + + uint currentElapsed = timer.isNull() ? 0 : timer.elapsed(); + timer.restart(); + + m_total += currentElapsed; + + // warm up for at most 5 iterations or half a second + if (m_iteration >= 5 || m_total >= 500) { + iterationTimes << currentElapsed; + + if (iterationTimes.size() >= 5) { + qreal mean = 0; + qreal stddev = 0; + uint min = INT_MAX; + + for (int i = 0; i < iterationTimes.size(); ++i) { + mean += iterationTimes.at(i); + min = qMin(min, iterationTimes.at(i)); + } + + mean /= qreal(iterationTimes.size()); + + for (int i = 0; i < iterationTimes.size(); ++i) { + qreal delta = iterationTimes.at(i) - mean; + stddev += delta * delta; + } + + stddev = qSqrt(stddev / iterationTimes.size()); + + stddev = 100 * stddev / mean; + // do 50 iterations, break earlier if we spend more than 5 seconds or have a low std deviation after 2 seconds + if (iterationTimes.size() >= 50 || m_total >= 5000 || (m_total >= 2000 && stddev < 4)) { + m_result = min; + m_done = true; + return; + } + } + } +} + +BenchWidget::BenchWidget(Benchmark *benchmark) + : m_benchmark(benchmark) + , m_done(false) + , m_result(0) + , m_total(0) + , m_iteration(0) +{ + setWindowTitle(benchmark->name()); + resize(640, 480); +} + +class tst_QtBench : public QObject +{ + Q_OBJECT + +private slots: + void qtBench(); + void qtBench_data(); +}; + +QString makeString(int length) +{ + const char chars[] = "abcd efgh ijkl mnop qrst uvwx yz!$. ABCD 1234"; + int len = strlen(chars); + + QString ret; + for (int j = 0; j < length; j++) { + ret += QChar(chars[(j * 97) % len]); + } + + return ret; +} + +void tst_QtBench::qtBench_data() +{ + QTest::addColumn<void *>("benchmark"); + + QString shortString = makeString(5); + QString middleString = makeString(50); + QString longString = makeString(35) + "\n" + + makeString(45) + "\n" + + makeString(75); + QString superLongString = "Lorem ipsum dolor sit am\n" + "et, consectetur adipisci\n" + "ng elit. Integer mi leo,\n" + "interdum ut congue at, p\n" + "ulvinar et tellus. Quisq\n" + "ue pretium eleifend laci\n" + "nia. Ut semper gravida l\n" + "ectus in commodo. Vestib\n" + "ulum pharetra arcu in en\n" + "im ultrices hendrerit. P\n" + "ellentesque habitant mor\n" + "bi tristique senectus et\n" + "netus et malesuada fames\n" + "ac turpis egestas. Ut er\n" + "os sem, feugiat in eleme\n" + "ntum in, porta sit amet \n" + "neque. Fusce mi tellus, \n" + "congue non dapibus eget,\n" + "pharetra quis quam. Duis\n" + "dui massa, pulvinar ac s\n" + "odales pharetra, dictum \n" + "in enim. Phasellus a nis\n" + "i erat, sed pellentesque\n" + "mi. Curabitur sed."; + + QList<Benchmark *> benchmarks; + benchmarks << (new DrawText(shortString, DrawText::PainterMode)); + benchmarks << (new DrawText(middleString, DrawText::PainterMode)); + benchmarks << (new DrawText(longString, DrawText::PainterMode)); + benchmarks << (new DrawText(superLongString, DrawText::PainterMode)); + + benchmarks << (new DrawText(shortString, DrawText::PainterQPointMode)); + benchmarks << (new DrawText(middleString, DrawText::PainterQPointMode)); + benchmarks << (new DrawText(longString, DrawText::PainterQPointMode)); + benchmarks << (new DrawText(superLongString, DrawText::PainterQPointMode)); + + benchmarks << (new DrawText(shortString, DrawText::PixmapMode)); + benchmarks << (new DrawText(middleString, DrawText::PixmapMode)); + benchmarks << (new DrawText(longString, DrawText::PixmapMode)); + benchmarks << (new DrawText(superLongString, DrawText::PixmapMode)); + +#if QT_VERSION >= 0x040700 + benchmarks << (new DrawText(shortString, DrawText::StaticTextMode)); + benchmarks << (new DrawText(middleString, DrawText::StaticTextMode)); + benchmarks << (new DrawText(longString, DrawText::StaticTextMode)); + benchmarks << (new DrawText(superLongString, DrawText::StaticTextMode)); + + benchmarks << (new DrawText(shortString, DrawText::StaticTextWithMaximumSizeMode)); + benchmarks << (new DrawText(middleString, DrawText::StaticTextWithMaximumSizeMode)); + benchmarks << (new DrawText(longString, DrawText::StaticTextWithMaximumSizeMode)); + benchmarks << (new DrawText(superLongString, DrawText::StaticTextWithMaximumSizeMode)); + + benchmarks << (new DrawText(shortString, DrawText::StaticTextBackendOptimizations)); + benchmarks << (new DrawText(middleString, DrawText::StaticTextBackendOptimizations)); + benchmarks << (new DrawText(longString, DrawText::StaticTextBackendOptimizations)); + benchmarks << (new DrawText(superLongString, DrawText::StaticTextBackendOptimizations)); +#endif + + foreach (Benchmark *benchmark, benchmarks) + QTest::newRow(qPrintable(benchmark->name())) << reinterpret_cast<void *>(benchmark); +} + +void tst_QtBench::qtBench() +{ + QFETCH(void *, benchmark); + + BenchWidget widget(reinterpret_cast<Benchmark *>(benchmark)); + widget.show(); + QTest::qWaitForWindowShown(&widget); + + while (!widget.done()) { + widget.update(); + QApplication::processEvents(); + } + + QTest::setBenchmarkResult(widget.result(), QTest::WalltimeMilliseconds); +} + +QTEST_MAIN(tst_QtBench) +#include "tst_qtbench.moc" 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/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 |