diff options
Diffstat (limited to 'tests/auto')
16 files changed, 295 insertions, 15 deletions
diff --git a/tests/auto/linguist/lupdate/testdata/good/namespaces/main.cpp b/tests/auto/linguist/lupdate/testdata/good/namespaces/main.cpp index 42cc55b..a5b36ca 100644 --- a/tests/auto/linguist/lupdate/testdata/good/namespaces/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/namespaces/main.cpp @@ -135,4 +135,64 @@ Q_OBJECT } }; +// QTBUG-8360 +namespace A { + +void foo() +{ + using namespace A; +} + +void goo() +{ + return QObject::tr("Bla"); +} + +} + + +namespace AA { +namespace B { + +using namespace AA; + +namespace C { + +class Test : public QObject { + Q_OBJECT +}; + +} + +} + +using namespace B; +using namespace C; + +void goo() +{ + AA::Test::tr("howdy?"); +} + +} + + +namespace A1 { +namespace B { + +class Test : public QObject { + Q_OBJECT +}; + +using namespace A1; + +void foo() +{ + B::B::B::Test::tr("yeeee-ha!"); +} + +} +} + + #include "main.moc" diff --git a/tests/auto/linguist/lupdate/testdata/good/namespaces/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/namespaces/project.ts.result index c1a34bd..94df9d3 100644 --- a/tests/auto/linguist/lupdate/testdata/good/namespaces/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/namespaces/project.ts.result @@ -2,6 +2,22 @@ <!DOCTYPE TS> <TS version="2.0"> <context> + <name>A1::B::Test</name> + <message> + <location filename="main.cpp" line="191"/> + <source>yeeee-ha!</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>AA::B::C::Test</name> + <message> + <location filename="main.cpp" line="174"/> + <source>howdy?</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> <name>Class</name> <message> <location filename="main.cpp" line="52"/> @@ -79,4 +95,12 @@ <translation type="unfinished"></translation> </message> </context> +<context> + <name>QObject</name> + <message> + <location filename="main.cpp" line="148"/> + <source>Bla</source> + <translation type="unfinished"></translation> + </message> +</context> </TS> diff --git a/tests/auto/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp index d1b2ea5..caf08d6 100644 --- a/tests/auto/qdom/tst_qdom.cpp +++ b/tests/auto/qdom/tst_qdom.cpp @@ -131,6 +131,7 @@ private slots: void setContentWhitespace_data() const; void taskQTBUG4595_dontAssertWhenDocumentSpecifiesUnknownEncoding() const; + void cloneDTD_QTBUG8398() const; void cleanupTestCase() const; @@ -1912,5 +1913,29 @@ void tst_QDom::taskQTBUG4595_dontAssertWhenDocumentSpecifiesUnknownEncoding() co QVERIFY(true); } +void tst_QDom::cloneDTD_QTBUG8398() const +{ + QString dtd("<?xml version='1.0' encoding='UTF-8'?>\n" + "<!DOCTYPE first [\n" + "<!ENTITY secondFile SYSTEM 'second.xml'>\n" + "<!ENTITY thirdFile SYSTEM 'third.xml'>\n" + "]>\n" + "<first/>\n"); + QDomDocument domDocument; + QVERIFY(domDocument.setContent(dtd)); + QDomDocument domDocument2 = domDocument.cloneNode(true).toDocument(); + + // for some reason, our DOM implementation reverts the order of entities + QString expected("<?xml version='1.0' encoding='UTF-8'?>\n" + "<!DOCTYPE first [\n" + "<!ENTITY thirdFile SYSTEM 'third.xml'>\n" + "<!ENTITY secondFile SYSTEM 'second.xml'>\n" + "]>\n" + "<first/>\n"); + QString output; + QTextStream stream(&output); + domDocument2.save(stream, 0); + QCOMPARE(output, expected); +} QTEST_MAIN(tst_QDom) #include "tst_qdom.moc" diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 41b9734..5339132 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -205,6 +205,13 @@ private slots: void QTBUG_6618(); void QTBUG_6852_data() { generic_data("QMYSQL"); } void QTBUG_6852(); + void QTBUG_5765_data() { generic_data("QMYSQL"); } + void QTBUG_5765(); + +#if 0 + void benchmark_data() { generic_data(); } + void benchmark(); +#endif private: // returns all database connections @@ -309,7 +316,14 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) << qTableName( "blobstest" ) << qTableName( "oraRowId" ) << qTableName( "qtest_batch" ) - << qTableName(QLatin1String("bug6421")).toUpper(); + << qTableName("bug6421").toUpper() + << qTableName("bug5765") + << qTableName("bug6852") + << qTableName( "qtest_lockedtable" ) + << qTableName( "Planet" ) + << qTableName( "task_250026" ) + << qTableName( "task_234422" ) + << qTableName("test141895"); if ( db.driverName().startsWith("QPSQL") ) tablenames << qTableName("task_233829"); @@ -320,19 +334,11 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QOCI" ) ) tablenames << qTableName( "qtest_longstr" ); - tablenames << qTableName( "qtest_lockedtable" ); - - tablenames << qTableName( "Planet" ); + if (tst_Databases::isSqlServer( db )) + db.exec("DROP PROCEDURE " + qTableName("test141895_proc")); - tablenames << qTableName( "task_250026" ); - tablenames << qTableName( "task_234422" ); - - if (tst_Databases::isSqlServer( db )) { - QSqlQuery q( db ); - q.exec("DROP PROCEDURE " + qTableName("test141895_proc")); - } - - tablenames << qTableName("test141895"); + if (tst_Databases::isMySQL( db )) + db.exec("DROP PROCEDURE IF EXISTS "+qTableName("bug6852_proc")); tst_Databases::safeDropTables( db, tablenames ); @@ -2996,10 +3002,9 @@ void tst_QSqlQuery::QTBUG_6852() QSKIP( "Test requires MySQL >= 5.0", SkipSingle ); QSqlQuery q(db); - QString tableName(qTableName(QLatin1String("bug6421"))), procName(qTableName(QLatin1String("bug6421_proc"))); + QString tableName(qTableName(QLatin1String("bug6852"))), procName(qTableName(QLatin1String("bug6852_proc"))); QVERIFY_SQL(q, exec("DROP PROCEDURE IF EXISTS "+procName)); - tst_Databases::safeDropTable(db, tableName); QVERIFY_SQL(q, exec("CREATE TABLE "+tableName+"(\n" "MainKey INT NOT NULL,\n" "OtherTextCol VARCHAR(45) NOT NULL,\n" @@ -3022,6 +3027,72 @@ void tst_QSqlQuery::QTBUG_6852() QCOMPARE(q.value(1).toString(), QLatin1String("Disabled")); } +void tst_QSqlQuery::QTBUG_5765() +{ + QFETCH( QString, dbName ); + QSqlDatabase db = QSqlDatabase::database( dbName ); + CHECK_DATABASE( db ); + if ( tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 1 ).toFloat()<4.1 ) + QSKIP( "Test requires MySQL >= 4.1", SkipSingle ); + + QSqlQuery q(db); + QString tableName(qTableName(QLatin1String("bug5765"))); + + QVERIFY_SQL(q, exec("CREATE TABLE "+tableName+"(testval TINYINT(1) DEFAULT 0)")); + q.prepare("INSERT INTO "+tableName+" SET testval = :VALUE"); + q.bindValue(":VALUE", 1); + QVERIFY_SQL(q, exec()); + q.bindValue(":VALUE", 12); + QVERIFY_SQL(q, exec()); + q.bindValue(":VALUE", 123); + QVERIFY_SQL(q, exec()); + QString sql="select testval from "+tableName; + QVERIFY_SQL(q, exec(sql)); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 1); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 12); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 123); + QVERIFY_SQL(q, prepare(sql)); + QVERIFY_SQL(q, exec()); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 1); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 12); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toInt(), 123); +} + +#if 0 +void tst_QSqlQuery::benchmark() +{ + QFETCH( QString, dbName ); + QSqlDatabase db = QSqlDatabase::database( dbName ); + CHECK_DATABASE( db ); + if ( tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 ) + QSKIP( "Test requires MySQL >= 5.0", SkipSingle ); + + QSqlQuery q(db); + QString tableName(qTableName(QLatin1String("benchmark"))); + + tst_Databases::safeDropTable( db, tableName ); + + QVERIFY_SQL(q, exec("CREATE TABLE "+tableName+"(\n" + "MainKey INT NOT NULL,\n" + "OtherTextCol VARCHAR(45) NOT NULL,\n" + "PRIMARY KEY(`MainKey`))")); + + int i=1; + + QBENCHMARK { + QVERIFY_SQL(q, exec("INSERT INTO "+tableName+" VALUES("+QString::number(i)+", \"Value"+QString::number(i)+"\")")); + i++; + } + + tst_Databases::safeDropTable( db, tableName ); +} +#endif QTEST_MAIN( tst_QSqlQuery ) #include "tst_qsqlquery.moc" diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index a5cbbd4..54e32218 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -200,6 +200,8 @@ private slots: void taskQTBUG_4516_clickOnRichTextLabel(); void taskQTBUG_5237_wheelEventOnHeader(); void taskQTBUG_8585_crashForNoGoodReason(); + void taskQTBUG_7774_RtoLVisualRegionForSelection(); + void taskQTBUG_8777_scrollToSpans(); void mouseWheel_data(); void mouseWheel(); @@ -3993,6 +3995,44 @@ void tst_QTableView::taskQTBUG_8585_crashForNoGoodReason() } } +class TableView7774 : public QTableView +{ +public: + QRegion visualRegionForSelection(const QItemSelection &selection) const + { + return QTableView::visualRegionForSelection(selection); + } +}; + +void tst_QTableView::taskQTBUG_7774_RtoLVisualRegionForSelection() +{ + TableView7774 view; + QStandardItemModel model(5,5); + view.setModel(&model); + view.setLayoutDirection(Qt::RightToLeft); + view.show(); + QTest::qWaitForWindowShown(&view); + + QItemSelectionRange range(model.index(2, 0), model.index(2, model.columnCount() - 1)); + QItemSelection selection; + selection << range; + QRegion region = view.visualRegionForSelection(selection); + 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/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) |