From c59f1aea65fbe4b3fea23d640e9917f03dc78c05 Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Fri, 22 Mar 2013 14:55:23 +0800 Subject: QtSql tests: Remove DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 Change-Id: I93169244b51f8b993f97f7595e0bc7006ae04e3a Reviewed-by: Mark Brand --- tests/auto/sql/kernel/qsql/qsql.pro | 1 - tests/auto/sql/kernel/qsqldatabase/qsqldatabase.pro | 1 - tests/auto/sql/kernel/qsqldriver/qsqldriver.pro | 1 - tests/auto/sql/kernel/qsqlerror/qsqlerror.pro | 1 - tests/auto/sql/kernel/qsqlfield/qsqlfield.pro | 1 - tests/auto/sql/kernel/qsqlquery/qsqlquery.pro | 1 - tests/auto/sql/kernel/qsqlrecord/qsqlrecord.pro | 1 - tests/auto/sql/kernel/qsqlresult/qsqlresult.pro | 1 - tests/auto/sql/kernel/qsqlthread/qsqlthread.pro | 1 - tests/auto/sql/models/qsqlquerymodel/qsqlquerymodel.pro | 1 - .../sql/models/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro | 1 - tests/auto/sql/models/qsqltablemodel/qsqltablemodel.pro | 1 - 12 files changed, 12 deletions(-) (limited to 'tests') diff --git a/tests/auto/sql/kernel/qsql/qsql.pro b/tests/auto/sql/kernel/qsql/qsql.pro index 980a35b99f..c890352d45 100644 --- a/tests/auto/sql/kernel/qsql/qsql.pro +++ b/tests/auto/sql/kernel/qsql/qsql.pro @@ -10,4 +10,3 @@ wince*: { } win32-g++*: LIBS += -lws2_32 -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/sql/kernel/qsqldatabase/qsqldatabase.pro b/tests/auto/sql/kernel/qsqldatabase/qsqldatabase.pro index ae11916a72..89dc7a5c7c 100644 --- a/tests/auto/sql/kernel/qsqldatabase/qsqldatabase.pro +++ b/tests/auto/sql/kernel/qsqldatabase/qsqldatabase.pro @@ -17,4 +17,3 @@ wince*: { DEPLOYMENT += testData } -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/sql/kernel/qsqldriver/qsqldriver.pro b/tests/auto/sql/kernel/qsqldriver/qsqldriver.pro index de50f43b76..ef7bb70a94 100644 --- a/tests/auto/sql/kernel/qsqldriver/qsqldriver.pro +++ b/tests/auto/sql/kernel/qsqldriver/qsqldriver.pro @@ -17,4 +17,3 @@ wince*: { LIBS += ws2_32.lib } } -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/sql/kernel/qsqlerror/qsqlerror.pro b/tests/auto/sql/kernel/qsqlerror/qsqlerror.pro index 3076e1aa8b..c217e27645 100644 --- a/tests/auto/sql/kernel/qsqlerror/qsqlerror.pro +++ b/tests/auto/sql/kernel/qsqlerror/qsqlerror.pro @@ -8,4 +8,3 @@ TARGET = tst_qsqlerror QT = core sql testlib SOURCES += tst_qsqlerror.cpp -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/sql/kernel/qsqlfield/qsqlfield.pro b/tests/auto/sql/kernel/qsqlfield/qsqlfield.pro index 16ad209031..6b74041a17 100644 --- a/tests/auto/sql/kernel/qsqlfield/qsqlfield.pro +++ b/tests/auto/sql/kernel/qsqlfield/qsqlfield.pro @@ -4,4 +4,3 @@ TARGET = tst_qsqlfield SOURCES += tst_qsqlfield.cpp QT = core sql testlib -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/sql/kernel/qsqlquery/qsqlquery.pro b/tests/auto/sql/kernel/qsqlquery/qsqlquery.pro index 40c21cf51b..c1e2a7ebb1 100644 --- a/tests/auto/sql/kernel/qsqlquery/qsqlquery.pro +++ b/tests/auto/sql/kernel/qsqlquery/qsqlquery.pro @@ -13,4 +13,3 @@ wince*: { DEPLOYMENT += plugFiles LIBS += -lws2 } -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/sql/kernel/qsqlrecord/qsqlrecord.pro b/tests/auto/sql/kernel/qsqlrecord/qsqlrecord.pro index 5c71b07d33..0e92797bb0 100644 --- a/tests/auto/sql/kernel/qsqlrecord/qsqlrecord.pro +++ b/tests/auto/sql/kernel/qsqlrecord/qsqlrecord.pro @@ -4,4 +4,3 @@ TARGET = tst_qsqlrecord SOURCES += tst_qsqlrecord.cpp QT = core sql testlib -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/sql/kernel/qsqlresult/qsqlresult.pro b/tests/auto/sql/kernel/qsqlresult/qsqlresult.pro index abd32ee017..ef6c7a7e09 100644 --- a/tests/auto/sql/kernel/qsqlresult/qsqlresult.pro +++ b/tests/auto/sql/kernel/qsqlresult/qsqlresult.pro @@ -8,4 +8,3 @@ HEADERS += testsqldriver.h win32-g++*: LIBS += -lws2_32 -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/sql/kernel/qsqlthread/qsqlthread.pro b/tests/auto/sql/kernel/qsqlthread/qsqlthread.pro index 4bae8ba882..73247545ce 100644 --- a/tests/auto/sql/kernel/qsqlthread/qsqlthread.pro +++ b/tests/auto/sql/kernel/qsqlthread/qsqlthread.pro @@ -14,4 +14,3 @@ wince*: { win32:LIBS += -lws2_32 } -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/sql/models/qsqlquerymodel/qsqlquerymodel.pro b/tests/auto/sql/models/qsqlquerymodel/qsqlquerymodel.pro index 915404c196..cbbd1d6eb7 100644 --- a/tests/auto/sql/models/qsqlquerymodel/qsqlquerymodel.pro +++ b/tests/auto/sql/models/qsqlquerymodel/qsqlquerymodel.pro @@ -11,4 +11,3 @@ wince*: { win32:LIBS += -lws2_32 } -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/sql/models/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro b/tests/auto/sql/models/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro index 90f26730bf..117ad5cbf6 100644 --- a/tests/auto/sql/models/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro +++ b/tests/auto/sql/models/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro @@ -16,4 +16,3 @@ wince*: { LIBS += ws2_32.lib } } -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/sql/models/qsqltablemodel/qsqltablemodel.pro b/tests/auto/sql/models/qsqltablemodel/qsqltablemodel.pro index 3ad44d61ef..e7d01afb40 100644 --- a/tests/auto/sql/models/qsqltablemodel/qsqltablemodel.pro +++ b/tests/auto/sql/models/qsqltablemodel/qsqltablemodel.pro @@ -13,4 +13,3 @@ wince*: { win32:LIBS += -lws2_32 } -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 -- cgit v1.2.3 From eb5d8d2fc30bb9588320eaada0abf1e69bddf980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 1 Mar 2013 12:41:43 +0100 Subject: Update the high-dpi manual test. - Organize the test images into different sizes. - Add a button and icon drawing test. - Don't show all tests by default. Change-Id: I95eff846b8c5159085f53b413dea7212c1ea5071 Reviewed-by: Gabriel de Dietrich --- tests/manual/highdpi/highdpi.qrc | 8 +- tests/manual/highdpi/main.cpp | 201 +++++++++++++++++++++++++++------- tests/manual/highdpi/qticon.png | Bin 6474 -> 0 bytes tests/manual/highdpi/qticon16.png | Bin 0 -> 1884 bytes tests/manual/highdpi/qticon16@2x.png | Bin 0 -> 3187 bytes tests/manual/highdpi/qticon32.png | Bin 0 -> 3187 bytes tests/manual/highdpi/qticon32@2x.png | Bin 0 -> 6474 bytes tests/manual/highdpi/qticon64.png | Bin 0 -> 6474 bytes tests/manual/highdpi/qticon@2x.png | Bin 17168 -> 0 bytes tests/manual/highdpi/qticon_large.png | Bin 17168 -> 0 bytes 10 files changed, 169 insertions(+), 40 deletions(-) delete mode 100644 tests/manual/highdpi/qticon.png create mode 100644 tests/manual/highdpi/qticon16.png create mode 100644 tests/manual/highdpi/qticon16@2x.png create mode 100644 tests/manual/highdpi/qticon32.png create mode 100644 tests/manual/highdpi/qticon32@2x.png create mode 100644 tests/manual/highdpi/qticon64.png delete mode 100644 tests/manual/highdpi/qticon@2x.png delete mode 100644 tests/manual/highdpi/qticon_large.png (limited to 'tests') diff --git a/tests/manual/highdpi/highdpi.qrc b/tests/manual/highdpi/highdpi.qrc index b43c2c07ad..10efac44fa 100644 --- a/tests/manual/highdpi/highdpi.qrc +++ b/tests/manual/highdpi/highdpi.qrc @@ -1,7 +1,9 @@ - qticon.png - qticon@2x.png - qticon_large.png + qticon16.png + qticon16@2x.png + qticon32.png + qticon32@2x.png + qticon64.png diff --git a/tests/manual/highdpi/main.cpp b/tests/manual/highdpi/main.cpp index fb1e06f0f1..d093569ea8 100644 --- a/tests/manual/highdpi/main.cpp +++ b/tests/manual/highdpi/main.cpp @@ -62,16 +62,16 @@ public: PixmapPainter::PixmapPainter() { - pixmap1X = QPixmap(":/qticon.png"); - pixmap2X = QPixmap(":/qticon@2x.png"); - pixmapLarge = QPixmap(":/qticon_large.png"); + pixmap1X = QPixmap(":/qticon32.png"); + pixmap2X = QPixmap(":/qticon32@2x.png"); + pixmapLarge = QPixmap(":/qticon64.png"); - image1X = QImage(":/qticon.png"); - image2X = QImage(":/qticon@2x.png"); - imageLarge = QImage(":/qticon_large.png"); + image1X = QImage(":/qticon32.png"); + image2X = QImage(":/qticon32@2x.png"); + imageLarge = QImage(":/qticon64.png"); - qtIcon.addFile(":/qticon.png"); - qtIcon.addFile(":/qticon@2x.png"); + qtIcon.addFile(":/qticon32.png"); + qtIcon.addFile(":/qticon32@2x.png"); } void PixmapPainter::paintEvent(QPaintEvent *event) @@ -79,12 +79,12 @@ void PixmapPainter::paintEvent(QPaintEvent *event) QPainter p(this); p.fillRect(QRect(QPoint(0, 0), size()), QBrush(Qt::gray)); - int pixmapPointSize = 64; + int pixmapPointSize = 32; int y = 30; - int dy = 150; + int dy = 90; int x = 10; - int dx = 80; + int dx = 40; // draw at point // qDebug() << "paint pixmap" << pixmap1X.devicePixelRatio(); p.drawPixmap(x, y, pixmap1X); @@ -95,7 +95,7 @@ void PixmapPainter::paintEvent(QPaintEvent *event) x+=dx;p.drawImage(x, y, image2X); x+=dx;p.drawImage(x, y, imageLarge); - // draw at 64x64 rect + // draw at 32x32 rect y+=dy; x = 10; p.drawPixmap(QRect(x, y, pixmapPointSize, pixmapPointSize), pixmap1X); @@ -107,7 +107,7 @@ void PixmapPainter::paintEvent(QPaintEvent *event) x+=dx;p.drawImage(QRect(x, y, pixmapPointSize, pixmapPointSize), imageLarge); - // draw at 128x128 rect + // draw at 64x64 rect y+=dy - 50; x = 10; p.drawPixmap(QRect(x, y, pixmapPointSize * 2, pixmapPointSize * 2), pixmap1X); @@ -132,12 +132,12 @@ public: Labels::Labels() { - pixmap1X = QPixmap(":/qticon.png"); - pixmap2X = QPixmap(":/qticon@2x.png"); - pixmapLarge = QPixmap(":/qticon_large.png"); + pixmap1X = QPixmap(":/qticon32.png"); + pixmap2X = QPixmap(":/qticon32@2x.png"); + pixmapLarge = QPixmap(":/qticon64.png"); - qtIcon.addFile(":/qticon.png"); - qtIcon.addFile(":/qticon@2x.png"); + qtIcon.addFile(":/qticon32.png"); + qtIcon.addFile(":/qticon32@2x.png"); setWindowIcon(qtIcon); setWindowTitle("Labels"); @@ -146,15 +146,15 @@ Labels::Labels() QLabel *label2x = new QLabel(); label2x->setPixmap(pixmap2X); QLabel *labelIcon = new QLabel(); - labelIcon->setPixmap(qtIcon.pixmap(QSize(64,64))); + labelIcon->setPixmap(qtIcon.pixmap(QSize(32,32))); QLabel *labelLarge = new QLabel(); labelLarge->setPixmap(pixmapLarge); QHBoxLayout *layout = new QHBoxLayout(this); -// layout->addWidget(label1x); //expected low-res on high-dpi displays - layout->addWidget(label2x); -// layout->addWidget(labelIcon); -// layout->addWidget(labelLarge); // expected large size and low-res + layout->addWidget(label1x); //expected low-res on high-dpi displays + layout->addWidget(label2x); //expected high-res on high-dpi displays + layout->addWidget(labelIcon); //expected high-res on high-dpi displays + layout->addWidget(labelLarge); // expected large size and low-res setLayout(layout); } @@ -172,16 +172,14 @@ public: MainWindow::MainWindow() { - qtIcon.addFile(":/qticon.png"); - qtIcon.addFile(":/qticon@2x.png"); - qtIcon1x.addFile(":/qticon.png"); - qtIcon2x.addFile(":/qticon@2x.png"); + // beware that QIcon auto-loads the @2x versions. + qtIcon1x.addFile(":/qticon16.png"); + qtIcon2x.addFile(":/qticon32.png"); setWindowIcon(qtIcon); setWindowTitle("MainWindow"); fileToolBar = addToolBar(tr("File")); // fileToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - fileToolBar->addAction(new QAction(qtIcon, QString("1x and 2x"), this)); fileToolBar->addAction(new QAction(qtIcon1x, QString("1x"), this)); fileToolBar->addAction(new QAction(qtIcon2x, QString("2x"), this)); } @@ -331,36 +329,165 @@ void apiTest() apiTestdevicePixelRatioSetter(); } +// Request and draw an icon at different sizes +class IconDrawing : public QWidget +{ +public: + QIcon *iconHighDPI; + QIcon *iconNormalDpi; + + IconDrawing() + { + QFile::copy(":/qticon32.png", "/tmp/qticon32-2.png"); + + QFile::copy(":/qticon32.png", "/tmp/qticon32.png"); + QFile::copy(":/qticon32@2x.png", "/tmp/qticon32@2x.png"); + + iconHighDPI = new QIcon("/tmp/qticon32.png"); // will auto-load @2x version. + iconNormalDpi = new QIcon("/tmp/qticon32-2.png"); // does not have a 2x version. + } + + ~IconDrawing() + { + delete iconHighDPI; + delete iconNormalDpi; +// Qile:: + } + + void paintEvent(QPaintEvent *event) + { + int x = 10; + int y = 10; + int dx = 50; + int dy = 50; + int maxX = 600; + int minSize = 5; + int maxSize = 64; + int sizeIncrement = 5; + + // Disable high-dpi icons + qApp->setAttribute(Qt::AA_UseHighDpiPixmaps, false); + + // normal icon + for (int size = minSize; size < maxSize; size += sizeIncrement) { + QPainter p(this); + p.drawPixmap(x, y, iconNormalDpi->pixmap(size, size)); + if (x + dx > maxX) + y+=dy; + x = ((x + dx) % maxX); + } + x = 10; + y+=dy; + + // high-dpi icon + for (int size = minSize; size < maxSize; size += sizeIncrement) { + QPainter p(this); + p.drawPixmap(x, y, iconHighDPI->pixmap(size, size)); + if (x + dx > maxX) + y+=dy; + x = ((x + dx) % maxX); + } + + x = 10; + y+=dy; + + // Enable high-dpi icons + qApp->setAttribute(Qt::AA_UseHighDpiPixmaps, true); + + // normal icon + for (int size = minSize; size < maxSize; size += sizeIncrement) { + QPainter p(this); + p.drawPixmap(x, y, iconNormalDpi->pixmap(size, size)); + if (x + dx > maxX) + y+=dy; + x = ((x + dx) % maxX); + } + x = 10; + y+=dy; + + // high-dpi icon (draw point) + for (int size = minSize; size < maxSize; size += sizeIncrement) { + QPainter p(this); + p.drawPixmap(x, y, iconHighDPI->pixmap(size, size)); + if (x + dx > maxX) + y+=dy; + x = ((x + dx) % maxX); + } + + x = 10; + y+=dy; + + }; +}; + +// Icons on buttons +class Buttons : public QWidget +{ +public: + Buttons() + { + QIcon icon; + icon.addFile(":/qticon16@2x.png"); + + QPushButton *button = new QPushButton(this); + button->setIcon(icon); + button->setText("16@2x"); + + QTabBar *tab = new QTabBar(this); + tab->addTab(QIcon(":/qticon16.png"), "16@1x"); + tab->addTab(QIcon(":/qticon16@2x.png"), "16@2x"); + tab->addTab(QIcon(":/qticon16.png"), ""); + tab->addTab(QIcon(":/qticon16@2x.png"), ""); + tab->move(10, 100); + tab->show(); + + QToolBar *toolBar = new QToolBar(this); + toolBar->addAction(QIcon(":/qticon16.png"), "16"); + toolBar->addAction(QIcon(":/qticon16@2x.png"), "16@2x"); + toolBar->addAction(QIcon(":/qticon32.png"), "32"); + toolBar->addAction(QIcon(":/qticon32@2x.png"), "32@2x"); + + toolBar->move(10, 200); + toolBar->show(); + } +}; + + int main(int argc, char **argv) { - qputenv("QT_HIGHDPI_AWARE", "1"); QApplication app(argc, argv); + qApp->setAttribute(Qt::AA_UseHighDpiPixmaps); PixmapPainter pixmapPainter; - -// Enable for lots of pixmap drawing pixmapPainter.show(); Labels label; label.resize(200, 200); - label.show(); +// label.show(); MainWindow mainWindow; - mainWindow.show(); +// mainWindow.show(); StandardIcons icons; icons.resize(510, 510); - icons.show(); +// icons.show(); Caching caching; caching.resize(300, 300); - caching.show(); +// caching.show(); Style style; - style.show(); +// style.show(); Fonts fonts; - fonts.show(); +// fonts.show(); + + IconDrawing iconDrawing; +// iconDrawing.show(); + + Buttons buttons; +// buttons.show(); + return app.exec(); } diff --git a/tests/manual/highdpi/qticon.png b/tests/manual/highdpi/qticon.png deleted file mode 100644 index 76f02c6c96..0000000000 Binary files a/tests/manual/highdpi/qticon.png and /dev/null differ diff --git a/tests/manual/highdpi/qticon16.png b/tests/manual/highdpi/qticon16.png new file mode 100644 index 0000000000..b6b01a4d64 Binary files /dev/null and b/tests/manual/highdpi/qticon16.png differ diff --git a/tests/manual/highdpi/qticon16@2x.png b/tests/manual/highdpi/qticon16@2x.png new file mode 100644 index 0000000000..205461daf0 Binary files /dev/null and b/tests/manual/highdpi/qticon16@2x.png differ diff --git a/tests/manual/highdpi/qticon32.png b/tests/manual/highdpi/qticon32.png new file mode 100644 index 0000000000..205461daf0 Binary files /dev/null and b/tests/manual/highdpi/qticon32.png differ diff --git a/tests/manual/highdpi/qticon32@2x.png b/tests/manual/highdpi/qticon32@2x.png new file mode 100644 index 0000000000..76f02c6c96 Binary files /dev/null and b/tests/manual/highdpi/qticon32@2x.png differ diff --git a/tests/manual/highdpi/qticon64.png b/tests/manual/highdpi/qticon64.png new file mode 100644 index 0000000000..76f02c6c96 Binary files /dev/null and b/tests/manual/highdpi/qticon64.png differ diff --git a/tests/manual/highdpi/qticon@2x.png b/tests/manual/highdpi/qticon@2x.png deleted file mode 100644 index 0b00c00c96..0000000000 Binary files a/tests/manual/highdpi/qticon@2x.png and /dev/null differ diff --git a/tests/manual/highdpi/qticon_large.png b/tests/manual/highdpi/qticon_large.png deleted file mode 100644 index 0b00c00c96..0000000000 Binary files a/tests/manual/highdpi/qticon_large.png and /dev/null differ -- cgit v1.2.3 From f052cefc2fd223605a59c1eec4e53a71ddbfee39 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 26 Mar 2013 16:28:08 +0100 Subject: tst_qthread: fix race on "bool visited" Change-Id: I438bad9a4f8afb76272c8d8f08461a6d2c9a0b18 Reviewed-by: Olivier Goffart --- tests/auto/corelib/thread/qthread/tst_qthread.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index 7fbb5e9f5f..1ee628dde5 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -1221,9 +1221,9 @@ QT_END_NAMESPACE class DummyEventDispatcher : public QAbstractEventDispatcher { public: - DummyEventDispatcher() : QAbstractEventDispatcher(), visited(false) {} + DummyEventDispatcher() : QAbstractEventDispatcher() {} bool processEvents(QEventLoop::ProcessEventsFlags) { - visited = true; + visited.store(true); emit awake(); QCoreApplication::sendPostedEvents(); return false; @@ -1247,7 +1247,7 @@ public: void unregisterEventNotifier(QWinEventNotifier *) { } #endif - bool visited; + QBasicAtomicInt visited; // bool }; class ThreadObj : public QObject @@ -1285,7 +1285,7 @@ void tst_QThread::customEventDispatcher() QMetaObject::invokeMethod(&obj, "visit", Qt::QueuedConnection); loop.exec(); // test that the ED has really been used - QVERIFY(ed->visited); + QVERIFY(ed->visited.load()); QPointer weak_ed(ed); QVERIFY(!weak_ed.isNull()); -- cgit v1.2.3 From bc4dcb6994160ca7cb3776d42d419299d854aed9 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sat, 16 Mar 2013 09:21:52 +0200 Subject: QLocale: Report textDirection() by looking to the locale script Change-Id: Ic562b0301271ba414d5d3ff75a308d84bd288f56 Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qlocale/tst_qlocale.cpp | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index ed74c939f7..e3fe39a401 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -145,6 +145,9 @@ private slots: void measurementSystems(); void QTBUG_26035_positivesign(); + void textDirection_data(); + void textDirection(); + private: QString m_decimal, m_thousand, m_sdate, m_ldate, m_time; QString m_sysapp; @@ -1959,5 +1962,44 @@ void tst_QLocale::QTBUG_26035_positivesign() QVERIFY(ok); } +void tst_QLocale::textDirection_data() +{ + QTest::addColumn("language"); + QTest::addColumn("script"); + QTest::addColumn("rightToLeft"); + + for (int language = QLocale::C; language <= QLocale::LastLanguage; ++language) { + bool rightToLeft = false; + switch (language) { + case QLocale::Arabic: + case QLocale::Hebrew: + case QLocale::Kashmiri: + case QLocale::Persian: + case QLocale::Pashto: + case QLocale::Urdu: + case QLocale::Syriac: + case QLocale::Divehi: + rightToLeft = QLocale(QLocale::Language(language)).language() == QLocale::Language(language); // false if there is no locale data for language + break; + default: + break; + } + QString testName = QLocalePrivate::languageToCode(QLocale::Language(language)); + QTest::newRow(testName.toLatin1().constData()) << language << int(QLocale::AnyScript) << rightToLeft; + } + QTest::newRow("pa_Arab") << int(QLocale::Punjabi) << int(QLocale::ArabicScript) << true; + QTest::newRow("uz_Arab") << int(QLocale::Uzbek) << int(QLocale::ArabicScript) << true; +} + +void tst_QLocale::textDirection() +{ + QFETCH(int, language); + QFETCH(int, script); + QFETCH(bool, rightToLeft); + + QLocale locale(QLocale::Language(language), QLocale::Script(script), QLocale::AnyCountry); + QCOMPARE(locale.textDirection() == Qt::RightToLeft, rightToLeft); +} + QTEST_MAIN(tst_QLocale) #include "tst_qlocale.moc" -- cgit v1.2.3 From f0af3ed4e5b3656c9408522d0346b1c75f661135 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sat, 16 Mar 2013 09:23:32 +0200 Subject: Update QLocale data to CLDRv23 Say hello to Interlingua and Mongolian once again. Change-Id: I735fbc5793f34620be1f6932a251224b9ded02e3 Reviewed-by: Denis Dzyubenko Reviewed-by: Lars Knoll --- tests/auto/corelib/tools/qlocale/tst_qlocale.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index e3fe39a401..f8775bc75f 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -1636,10 +1637,10 @@ void tst_QLocale::defaultNumeringSystem() QCOMPARE(pa.toString(123), QLatin1String("123")); QLocale ne("ne_IN"); - QCOMPARE(ne.toString(123), QLatin1String("123")); + QCOMPARE(ne.toString(123), QString::fromUtf8("१२३")); QLocale mr("mr_IN"); - QCOMPARE(mr.toString(123), QLatin1String("123")); + QCOMPARE(mr.toString(123), QString::fromUtf8("१२३")); QLocale ml("ml_IN"); QCOMPARE(ml.toString(123), QLatin1String("123")); -- cgit v1.2.3 From bb5552a22995ba1dbc4f9944e72a6b0e15194fcb Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 21 Mar 2013 19:23:58 +0100 Subject: Upgrade the bundled PCRE to 8.32 Changelog: http://pcre.org/changelog.txt Amongst other things, the Unicode tables were upgraded to 6.2.0 and case folding support was added, which also fixes a QString autotest (marked as XFAIL). Qt still requires 8.30, not 8.32. Change-Id: I4056c1dc1d949d33443bb8ca280de4c8c363ac74 Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 91293ffc21..0a1af0a058 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -1164,8 +1164,6 @@ void tst_QString::indexOf() options |= QRegularExpression::CaseInsensitiveOption; QRegularExpression re(QRegularExpression::escape(needle), options); - QEXPECT_FAIL("data58", "QRegularExpression does not support case folding", Continue); - QEXPECT_FAIL("data59", "QRegularExpression does not support case folding", Continue); QCOMPARE( haystack.indexOf(re, startpos), resultpos ); } -- cgit v1.2.3 From b2ec0da95641d9cec006fa9699e6d082ad35db0b Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 3 Jan 2013 17:18:40 +0100 Subject: Cache QAccessibleInterfaces. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since there already is a one-to-one relationship between QObject and QAccessibleInterface it makes little sense to create and destroy the interfaces on each call to queryAccessibleInterface. Add a cache and keep created interfaces around for the lifetime of the corresponding QObject. This changes the memory management rules: accessible interfaces must no longer be deleted. If you get an QAccessibleIntrface pointer that pointer will stay valid as long as the corresponding QObject is not deleted. This also re-enables accessibility for Mac. We limit the range of the IDs so that they are useable for Windows directly. That means we can get rid of the event cache there. This is based on: Iebf2f374916fc70a9dd29e95f45a6444b85f6cee Change-Id: I9fe6531812c0dbc5b41101ac05830a6dd75e13a3 Reviewed-by: Morten Johan Sørvig --- tests/auto/other/macgui/guitest.cpp | 11 - tests/auto/other/macgui/guitest.h | 1 - .../other/qaccessibility/tst_qaccessibility.cpp | 343 +++++++++++---------- 3 files changed, 186 insertions(+), 169 deletions(-) (limited to 'tests') diff --git a/tests/auto/other/macgui/guitest.cpp b/tests/auto/other/macgui/guitest.cpp index 93e9db9a61..d7431dd88e 100644 --- a/tests/auto/other/macgui/guitest.cpp +++ b/tests/auto/other/macgui/guitest.cpp @@ -84,7 +84,6 @@ public: void WidgetNavigator::printAll(QWidget *widget) { QAccessibleInterface * const iface = QAccessible::queryAccessibleInterface(widget); - deleteInDestructor(iface); printAll(iface); } @@ -97,7 +96,6 @@ void WidgetNavigator::printAll(QAccessibleInterface *interface) QAccessibleInterface *WidgetNavigator::find(QAccessible::Text textType, const QString &text, QWidget *start) { QAccessibleInterface *const iface = QAccessible::queryAccessibleInterface(start); - deleteInDestructor(iface); return find(textType, text, iface); } @@ -127,18 +125,12 @@ QAccessibleInterface *WidgetNavigator::recursiveSearch(TestBase *test, QAccessib QAccessibleInterface *childInterface = testInterface->child(i); if (childInterface) { todoInterfaces.push(childInterface); - deleteInDestructor(childInterface); } } } return 0; } -void WidgetNavigator::deleteInDestructor(QAccessibleInterface *interface) -{ - interfaces.insert(interface); -} - QWidget *WidgetNavigator::getWidget(QAccessibleInterface *interface) { return qobject_cast(interface->object()); @@ -146,9 +138,6 @@ QWidget *WidgetNavigator::getWidget(QAccessibleInterface *interface) WidgetNavigator::~WidgetNavigator() { - foreach(QAccessibleInterface *interface, interfaces) { - delete interface; - } } /////////////////////////////////////////////////////////////////////////////// diff --git a/tests/auto/other/macgui/guitest.h b/tests/auto/other/macgui/guitest.h index 2d02cce720..569a67d7fe 100644 --- a/tests/auto/other/macgui/guitest.h +++ b/tests/auto/other/macgui/guitest.h @@ -76,7 +76,6 @@ public: QAccessibleInterface *recursiveSearch(TestBase *test, QAccessibleInterface *iface); - void deleteInDestructor(QAccessibleInterface * interface); static QWidget *getWidget(QAccessibleInterface *interface); private: QSet interfaces; diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index e168c13d42..670beff40b 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -68,7 +68,8 @@ # undef interface #endif - +#include +#include #include "QtTest/qtestaccessible.h" // Make a widget frameless to prevent size constraints of title bars @@ -95,8 +96,6 @@ inline bool IsValidCEPlatform() { } #endif -typedef QSharedPointer QAIPtr; - static inline bool verifyChild(QWidget *child, QAccessibleInterface *interface, int index, const QRect &domain) { @@ -111,7 +110,7 @@ static inline bool verifyChild(QWidget *child, QAccessibleInterface *interface, } // Verify that we get a valid QAccessibleInterface for the child. - QAIPtr childInterface(QAccessible::queryAccessibleInterface(child)); + QAccessibleInterface *childInterface(QAccessible::queryAccessibleInterface(child)); if (!childInterface) { qWarning("tst_QAccessibility::verifyChild: Failed to retrieve interface for child."); return false; @@ -119,7 +118,7 @@ static inline bool verifyChild(QWidget *child, QAccessibleInterface *interface, // QAccessibleInterface::indexOfChild(): // Verify that indexOfChild() returns an index equal to the index passed in - int indexFromIndexOfChild = interface->indexOfChild(childInterface.data()); + int indexFromIndexOfChild = interface->indexOfChild(childInterface); if (indexFromIndexOfChild != index) { qWarning("tst_QAccessibility::verifyChild (indexOfChild()):"); qWarning() << "Expected:" << index; @@ -128,7 +127,7 @@ static inline bool verifyChild(QWidget *child, QAccessibleInterface *interface, } // Navigate to child, compare its object and role with the interface from queryAccessibleInterface(child). - QAIPtr navigatedChildInterface(interface->child(index)); + QAccessibleInterface *navigatedChildInterface(interface->child(index)); if (!navigatedChildInterface) return false; @@ -138,7 +137,7 @@ static inline bool verifyChild(QWidget *child, QAccessibleInterface *interface, // Calculate global child position and check that the interface // returns the correct index for that position. QPoint globalChildPos = child->mapToGlobal(QPoint(0, 0)); - QAIPtr childAtInterface(interface->childAt(globalChildPos.x(), globalChildPos.y())); + QAccessibleInterface *childAtInterface(interface->childAt(globalChildPos.x(), globalChildPos.y())); if (!childAtInterface) { qWarning("tst_QAccessibility::verifyChild (childAt()):"); qWarning() << "Expected:" << childInterface; @@ -176,10 +175,10 @@ static inline int indexOfChild(QAccessibleInterface *parentInterface, QWidget *c { if (!parentInterface || !childWidget) return -1; - QAIPtr childInterface(QAccessible::queryAccessibleInterface(childWidget)); + QAccessibleInterface *childInterface(QAccessible::queryAccessibleInterface(childWidget)); if (!childInterface) return -1; - return parentInterface->indexOfChild(childInterface.data()); + return parentInterface->indexOfChild(childInterface); } #define EXPECT(cond) \ @@ -195,20 +194,20 @@ static int verifyHierarchy(QAccessibleInterface *iface) { int errorAt = 0; static int treelevel = 0; // for error diagnostics - QAIPtr middleChild; - QAIPtr if2; + QAccessibleInterface *if2 = 0; ++treelevel; for (int i = 0; i < iface->childCount() && !errorAt; ++i) { - if2 = QAIPtr(iface->child(i)); + if2 = iface->child(i); EXPECT(if2 != 0); - EXPECT(iface->indexOfChild(if2.data()) == i); + EXPECT(iface->indexOfChild(if2) == i); // navigate Ancestor - QAIPtr parent(if2->parent()); + QAccessibleInterface *parent = if2->parent(); EXPECT(iface->object() == parent->object()); + EXPECT(iface == parent); // verify children if (!errorAt) - errorAt = verifyHierarchy(if2.data()); + errorAt = verifyHierarchy(if2); } --treelevel; @@ -217,7 +216,7 @@ static int verifyHierarchy(QAccessibleInterface *iface) QRect childRect(QAccessibleInterface *iface, int index = 0) { - return QAIPtr(iface->child(index))->rect(); + return iface->child(index)->rect(); } class tst_QAccessibility : public QObject @@ -287,7 +286,7 @@ private: QAccessible::State state(QWidget * const widget) { - QAIPtr iface(QAccessible::queryAccessibleInterface(widget)); + QAccessibleInterface *iface(QAccessible::queryAccessibleInterface(widget)); if (!iface) { qWarning() << "Cannot get QAccessibleInterface for widget"; return QAccessible::State(); @@ -340,6 +339,7 @@ void tst_QAccessibility::cleanup() void tst_QAccessibility::eventTest() { QPushButton* button = new QPushButton(0); + QAccessible::queryAccessibleInterface(button); button->setObjectName(QString("Olaf")); setFrameless(button); @@ -436,7 +436,6 @@ void tst_QAccessibility::customWidget() QCOMPARE(iface->rect().height(), widget->height()); QCOMPARE(iface->text(QAccessible::Help), QString()); QCOMPARE(iface->rect().height(), widget->height()); - delete iface; delete widget; } { @@ -452,7 +451,6 @@ void tst_QAccessibility::customWidget() QCOMPARE(iface->rect().height(), widget->height()); // The help text is only set if our factory works QCOMPARE(iface->text(QAccessible::Help), QString("Help yourself")); - delete iface; delete widget; } { @@ -463,7 +461,6 @@ void tst_QAccessibility::customWidget() QVERIFY(subIface->isValid()); QCOMPARE(subIface->object(), (QObject*)subclassedWidget); QCOMPARE(subIface->text(QAccessible::Help), QString("Help yourself")); - delete subIface; delete subclassedWidget; } QTestAccessibility::clearEvents(); @@ -480,8 +477,7 @@ void tst_QAccessibility::deletedWidget() delete widget; widget = 0; - QVERIFY(!iface->isValid()); - delete iface; + // fixme: QVERIFY(!iface->isValid()); } class KFooButton: public QPushButton @@ -499,7 +495,6 @@ void tst_QAccessibility::subclassedWidget() QVERIFY(iface); QCOMPARE(iface->object(), (QObject*)&button); QCOMPARE(iface->text(QAccessible::Name), button.text()); - delete iface; QTestAccessibility::clearEvents(); } @@ -530,7 +525,7 @@ void tst_QAccessibility::sliderTest() setFrameless(slider); slider->setObjectName(QString("Slidy")); slider->show(); - QAIPtr iface(QAccessible::queryAccessibleInterface(slider)); + QAccessibleInterface *iface(QAccessible::queryAccessibleInterface(slider)); QVERIFY(iface); QVERIFY(iface->isValid()); @@ -577,16 +572,16 @@ void tst_QAccessibility::navigateHierarchy() w31->setObjectName(QString("31")); w31->show(); - QAIPtr ifaceW(QAccessible::queryAccessibleInterface(w)); + QAccessibleInterface *ifaceW(QAccessible::queryAccessibleInterface(w)); QVERIFY(ifaceW != 0); QVERIFY(ifaceW->isValid()); - QAIPtr target = QAIPtr(ifaceW->child(14)); + QAccessibleInterface *target = ifaceW->child(14); QVERIFY(target == 0); - target = QAIPtr(ifaceW->child(-1)); + target = ifaceW->child(-1); QVERIFY(target == 0); - target = QAIPtr(ifaceW->child(0)); - QAIPtr interfaceW1(ifaceW->child(0)); + target = ifaceW->child(0); + QAccessibleInterface *interfaceW1(ifaceW->child(0)); QVERIFY(target); QVERIFY(target->isValid()); QCOMPARE(target->object(), (QObject*)w1); @@ -594,24 +589,24 @@ void tst_QAccessibility::navigateHierarchy() QVERIFY(interfaceW1->isValid()); QCOMPARE(interfaceW1->object(), (QObject*)w1); - target = QAIPtr(ifaceW->child(2)); + target = ifaceW->child(2); QVERIFY(target != 0); QVERIFY(target->isValid()); QCOMPARE(target->object(), (QObject*)w3); - QAIPtr child = QAIPtr(target->child(1)); + QAccessibleInterface *child = target->child(1); QVERIFY(child == 0); - child = QAIPtr(target->child(0)); + child = target->child(0); QVERIFY(child != 0); QVERIFY(child->isValid()); QCOMPARE(child->object(), (QObject*)w31); - ifaceW = QAIPtr(QAccessible::queryAccessibleInterface(w)); - QAIPtr acc3(ifaceW->child(2)); - target = QAIPtr(acc3->child(0)); + ifaceW = QAccessible::queryAccessibleInterface(w); + QAccessibleInterface *acc3(ifaceW->child(2)); + target = acc3->child(0); QCOMPARE(target->object(), (QObject*)w31); - QAIPtr parent = QAIPtr(target->parent()); + QAccessibleInterface *parent = target->parent(); QVERIFY(parent != 0); QVERIFY(parent->isValid()); QCOMPARE(parent->object(), (QObject*)w3); @@ -807,7 +802,6 @@ void tst_QAccessibility::actionTest() widget->setFocusPolicy(Qt::StrongFocus); QCOMPARE(actions->actionNames(), QStringList(QAccessibleActionInterface::setFocusAction())); - delete interface; delete widget; } QTestAccessibility::clearEvents(); @@ -836,7 +830,6 @@ void tst_QAccessibility::actionTest() QTest::qWait(500); QCOMPARE(click_count, 1); - delete interface; delete button; } QTestAccessibility::clearEvents(); @@ -847,7 +840,7 @@ void tst_QAccessibility::applicationTest() { QLatin1String name = QLatin1String("My Name"); qApp->setApplicationName(name); - QAIPtr interface(QAccessible::queryAccessibleInterface(qApp)); + QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(qApp); QCOMPARE(interface->text(QAccessible::Name), name); QCOMPARE(interface->text(QAccessible::Description), qApp->applicationFilePath()); QCOMPARE(interface->text(QAccessible::Value), QString()); @@ -866,13 +859,13 @@ void tst_QAccessibility::applicationTest() qApp->setActiveWindow(&widget); QVERIFY(QTest::qWaitForWindowActive(&widget)); - QAIPtr widgetIface(QAccessible::queryAccessibleInterface(&widget)); + QAccessibleInterface *widgetIface = QAccessible::queryAccessibleInterface(&widget); QCOMPARE(interface->childCount(), 1); - QAIPtr focus(interface->focusChild()); + QAccessibleInterface *focus = interface->focusChild(); QCOMPARE(focus->object(), &widget); QCOMPARE(interface->indexOfChild(0), -1); - QCOMPARE(interface->indexOfChild(widgetIface.data()), 0); - QAIPtr child(interface->child(0)); + QCOMPARE(interface->indexOfChild(widgetIface), 0); + QAccessibleInterface *child = interface->child(0); QCOMPARE(child->object(), &widget); QCOMPARE(interface->child(-1), static_cast(0)); QCOMPARE(interface->child(1), static_cast(0)); @@ -906,7 +899,6 @@ void tst_QAccessibility::mainWindowTest() QVERIFY(iface->state().active); - delete iface; delete mw; } QTestAccessibility::clearEvents(); @@ -919,7 +911,7 @@ void tst_QAccessibility::mainWindowTest() // We currently don't have an accessible interface for QWindow // the active state is either in the QMainWindow or QQuickView -// QAIPtr windowIface(QAccessible::queryAccessibleInterface(&window)); +// QAccessibleInterface *windowIface(QAccessible::queryAccessibleInterface(&window)); // QVERIFY(windowIface->state().active); QAccessible::State activeState; @@ -1004,7 +996,6 @@ void tst_QAccessibility::buttonTest() actionInterface->doAction(QAccessibleActionInterface::pressAction()); QTest::qWait(500); QCOMPARE(pushButton.clickCount, 1); - delete interface; // test toggle button interface = QAccessible::queryAccessibleInterface(&toggleButton); @@ -1019,7 +1010,6 @@ void tst_QAccessibility::buttonTest() QVERIFY(toggleButton.isChecked()); QCOMPARE(actionInterface->actionNames().at(0), QAccessibleActionInterface::toggleAction()); QVERIFY(interface->state().checked); - delete interface; { // test menu push button @@ -1038,7 +1028,6 @@ void tst_QAccessibility::buttonTest() // showing the menu enters a new event loop... // interface->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction()); // QTest::qWait(500); - delete interface; delete menu; } @@ -1063,7 +1052,6 @@ void tst_QAccessibility::buttonTest() QVERIFY_EVENT(&ev); checkBox.setChecked(false); QVERIFY_EVENT(&ev); - delete interface; } { @@ -1082,7 +1070,6 @@ void tst_QAccessibility::buttonTest() st.checked = true; QAccessibleStateChangeEvent ev(&radio, st); QVERIFY_EVENT(&ev); - delete interface; } // // test standard toolbutton @@ -1175,7 +1162,6 @@ void tst_QAccessibility::scrollBarTest() const QRect scrollBarRect = scrollBarInterface->rect(); QVERIFY(scrollBarRect.isValid()); - delete scrollBarInterface; delete scrollBar; QTestAccessibility::clearEvents(); @@ -1196,7 +1182,6 @@ void tst_QAccessibility::tabTest() QAccessibleInterface *leftButton = interface->child(0); QCOMPARE(leftButton->role(), QAccessible::PushButton); QVERIFY(leftButton->state().invisible); - delete leftButton; const int lots = 5; for (int i = 0; i < lots; ++i) @@ -1232,9 +1217,6 @@ void tst_QAccessibility::tabTest() QCOMPARE(tabBar->currentIndex(), 1); delete tabBar; - delete interface; - delete child1; - delete child2; QTestAccessibility::clearEvents(); } @@ -1283,10 +1265,6 @@ void tst_QAccessibility::tabWidgetTest() QVERIFY(tabButtonRight); QCOMPARE(tabButtonRight->role(), QAccessible::PushButton); QCOMPARE(tabButtonRight->text(QAccessible::Name), QLatin1String("Scroll Right")); - delete tabButton1Interface; - delete tabButton2Interface; - delete tabButtonLeft; - delete tabButtonRight; QAccessibleInterface* stackWidgetInterface = interface->child(0); QVERIFY(stackWidgetInterface); @@ -1309,7 +1287,6 @@ void tst_QAccessibility::tabWidgetTest() QCOMPARE(parent->childCount(), 2); #endif QCOMPARE(parent->role(), QAccessible::LayeredPane); - delete parent; QAccessibleInterface* stackChild2Interface = stackWidgetInterface->child(1); QVERIFY(stackChild2Interface); @@ -1324,13 +1301,7 @@ void tst_QAccessibility::tabWidgetTest() QCOMPARE(parent->childCount(), 2); #endif QCOMPARE(parent->role(), QAccessible::LayeredPane); - delete parent; - delete tabBarInterface; - delete stackChild1Interface; - delete stackChild2Interface; - delete stackWidgetInterface; - delete interface; delete tabWidget; QTestAccessibility::clearEvents(); } @@ -1378,7 +1349,6 @@ void tst_QAccessibility::menuTest() QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&mw); QCOMPARE(verifyHierarchy(interface), 0); - delete interface; interface = QAccessible::queryAccessibleInterface(mw.menuBar()); @@ -1455,7 +1425,6 @@ void tst_QAccessibility::menuTest() QVERIFY(interface->actionInterface()); QCOMPARE(interface->actionInterface()->actionNames(), QStringList()); - delete interface; interface = QAccessible::queryAccessibleInterface(file); QCOMPARE(interface->childCount(), 5); QCOMPARE(interface->role(), QAccessible::PopupMenu); @@ -1496,9 +1465,7 @@ void tst_QAccessibility::menuTest() iface2 = interface->child(child); QVERIFY(iface2); QCOMPARE(iface2->role(), fileRoles[child]); - delete iface2; } - delete iface; // "New" item iface = interface->child(0); @@ -1507,20 +1474,16 @@ void tst_QAccessibility::menuTest() // "New" menu iface2 = iface->child(0); - delete iface; iface = iface2; QVERIFY(iface); QCOMPARE(iface->role(), QAccessible::PopupMenu); // "Text file" menu item iface2 = iface->child(0); - delete iface; iface = iface2; QVERIFY(iface); QCOMPARE(iface->role(), QAccessible::MenuItem); - delete iface; - // move mouse pointer away, since that might influence the // subsequent tests QTest::mouseMove(&mw, QPoint(-1, -1)); @@ -1539,13 +1502,6 @@ void tst_QAccessibility::menuTest() QTestAccessibility::clearEvents(); mw.hide(); - delete iFile; - delete iFileNew; - delete iFileOpen; - delete iFileSave; - delete iFileSeparator; - delete iFileExit; - // Do not crash if the menu don't have a parent QMenu *menu = new QMenu; menu->addAction(QLatin1String("one")); @@ -1557,8 +1513,6 @@ void tst_QAccessibility::menuTest() QCOMPARE(iface2->role(), QAccessible::Application); // caused a *crash* iface2->state(); - delete iface2; - delete iface; delete menu; } @@ -1590,7 +1544,6 @@ void tst_QAccessibility::spinBoxTest() QCOMPARE(lineEdit->role(), QAccessible::EditableText); QCOMPARE(lineEdit->text(QAccessible::Value), QLatin1String("3")); - delete lineEdit; QVERIFY(interface->valueInterface()); QCOMPARE(interface->valueInterface()->currentValue().toInt(), 3); @@ -1629,7 +1582,6 @@ void tst_QAccessibility::doubleSpinBoxTest() QAccessibleInterface *childIface = interface->child(i); const QRect childRect = childIface->rect(); QVERIFY(childRect.isValid()); - delete childIface; } delete doubleSpinBox; @@ -1887,7 +1839,6 @@ void tst_QAccessibility::mdiSubWindowTest() QAccessibleInterface *child = interface->childAt(globalWidgetPos.x(), globalWidgetPos.y()); QCOMPARE(child->role(), QAccessible::PushButton); QCOMPARE(child->text(QAccessible::Name), QString("QAccessibilityTest")); - delete child; testWindow->widget()->hide(); QCOMPARE(interface->childAt(globalWidgetPos.x(), globalWidgetPos.y()), static_cast(0)); @@ -1900,7 +1851,7 @@ void tst_QAccessibility::lineEditTest() QWidget *toplevel = new QWidget; { QLineEdit *le = new QLineEdit; - QAIPtr iface(QAccessible::queryAccessibleInterface(le)); + QAccessibleInterface *iface(QAccessible::queryAccessibleInterface(le)); QVERIFY(iface); le->show(); @@ -1966,7 +1917,7 @@ void tst_QAccessibility::lineEditTest() QString cite = "I always pass on good advice. It is the only thing to do with it. It is never of any use to oneself. --Oscar Wilde"; QLineEdit *le3 = new QLineEdit(cite, toplevel); le3->show(); - QAIPtr iface(QAccessible::queryAccessibleInterface(le3)); + QAccessibleInterface *iface(QAccessible::queryAccessibleInterface(le3)); QAccessibleTextInterface* textIface = iface->textInterface(); le3->deselect(); QTestAccessibility::clearEvents(); @@ -2028,7 +1979,7 @@ void tst_QAccessibility::lineEditTest() // characterRect() le.show(); QTest::qWaitForWindowShown(&le); - QAIPtr iface(QAccessible::queryAccessibleInterface(&le)); + QAccessibleInterface *iface(QAccessible::queryAccessibleInterface(&le)); QAccessibleTextInterface* textIface = iface->textInterface(); QVERIFY(textIface); const QRect lineEditRect = iface->rect(); @@ -2166,10 +2117,6 @@ void tst_QAccessibility::groupBoxTest() QCOMPARE(relation.first->object(), groupBox); QCOMPARE(relation.second, QAccessible::Label); - delete relation.first; - - delete rButtonIface; - delete iface; delete groupBox; } @@ -2199,7 +2146,6 @@ void tst_QAccessibility::groupBoxTest() QAccessibleStateChangeEvent ev2(groupBox, st); QVERIFY_EVENT(&ev2); - delete iface; delete groupBox; } } @@ -2265,7 +2211,6 @@ void tst_QAccessibility::dialogButtonBoxTest() break; } QCOMPARE(actualOrder, expectedOrder); - delete iface; QApplication::processEvents(); QTestAccessibility::clearEvents(); } @@ -2305,7 +2250,6 @@ void tst_QAccessibility::dialogButtonBoxTest() << QDialogButtonBox::tr("Help"); QCOMPARE(actualOrder, expectedOrder); - delete iface; QApplication::processEvents(); } @@ -2355,7 +2299,6 @@ void tst_QAccessibility::rubberBandTest() QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&rubberBand); QVERIFY(interface); QCOMPARE(interface->role(), QAccessible::Border); - delete interface; QTestAccessibility::clearEvents(); } @@ -2440,7 +2383,6 @@ void tst_QAccessibility::abstractScrollAreaTest() QCOMPARE(verifyHierarchy(interface), 0); - delete interface; } QTestAccessibility::clearEvents(); @@ -2458,7 +2400,6 @@ void tst_QAccessibility::scrollAreaTest() QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&scrollArea); QVERIFY(interface); QCOMPARE(interface->childCount(), 1); // The viewport. - delete interface; } QTestAccessibility::clearEvents(); } @@ -2476,27 +2417,27 @@ void tst_QAccessibility::listTest() QCoreApplication::processEvents(); QTest::qWait(100); - QAIPtr iface = QAIPtr(QAccessible::queryAccessibleInterface(listView)); - QCOMPARE(verifyHierarchy(iface.data()), 0); + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(listView); + QCOMPARE(verifyHierarchy(iface), 0); QCOMPARE((int)iface->role(), (int)QAccessible::List); QCOMPARE(iface->childCount(), 3); { - QAIPtr child1 = QAIPtr(iface->child(0)); + QAccessibleInterface *child1 = iface->child(0); QVERIFY(child1); - QCOMPARE(iface->indexOfChild(child1.data()), 0); + QCOMPARE(iface->indexOfChild(child1), 0); QCOMPARE(child1->text(QAccessible::Name), QString("Oslo")); QCOMPARE(child1->role(), QAccessible::ListItem); - QAIPtr child2 = QAIPtr(iface->child(1)); + QAccessibleInterface *child2 = iface->child(1); QVERIFY(child2); - QCOMPARE(iface->indexOfChild(child2.data()), 1); + QCOMPARE(iface->indexOfChild(child2), 1); QCOMPARE(child2->text(QAccessible::Name), QString("Berlin")); - QAIPtr child3 = QAIPtr(iface->child(2)); + QAccessibleInterface *child3 = iface->child(2); QVERIFY(child3); - QCOMPARE(iface->indexOfChild(child3.data()), 2); + QCOMPARE(iface->indexOfChild(child3), 2); QCOMPARE(child3->text(QAccessible::Name), QString("Brisbane")); } QTestAccessibility::clearEvents(); @@ -2526,11 +2467,11 @@ void tst_QAccessibility::listTest() QVERIFY(table2); QCOMPARE(table2->columnCount(), 1); QCOMPARE(table2->rowCount(), 4); - QAIPtr cell1 = QAIPtr(table2->cellAt(0,0)); + QAccessibleInterface *cell1 = table2->cellAt(0,0); QVERIFY(cell1); QCOMPARE(cell1->text(QAccessible::Name), QString("Oslo")); - QAIPtr cell4 = QAIPtr(table2->cellAt(3,0)); + QAccessibleInterface *cell4 = table2->cellAt(3,0); QVERIFY(cell4); QCOMPARE(cell4->text(QAccessible::Name), QString("Munich")); QCOMPARE(cell4->role(), QAccessible::ListItem); @@ -2544,7 +2485,7 @@ void tst_QAccessibility::listTest() QCOMPARE(cellInterface->rowHeaderCells(), QList()); QCOMPARE(cellInterface->columnHeaderCells(), QList()); - QCOMPARE(QAIPtr(cellInterface->table())->object(), listView); + QCOMPARE(cellInterface->table()->object(), listView); listView->clearSelection(); QVERIFY(!(cell4->state().expandable)); @@ -2561,6 +2502,25 @@ void tst_QAccessibility::listTest() QVERIFY(table2->cellAt(0, 1) == 0); QVERIFY(table2->cellAt(4, 0) == 0); + // verify that unique id stays the same + QAccessible::Id axidMunich = QAccessible::uniqueId(cell4); + // insertion and deletion of items + listView->insertItem(1, "Helsinki"); + // list: Oslo, Helsinki, Berlin, Brisbane, Munich + + QAccessibleInterface *cellMunich2 = table2->cellAt(4,0); + QCOMPARE(cell4, cellMunich2); + QCOMPARE(axidMunich, QAccessible::uniqueId(cellMunich2)); + + delete listView->takeItem(2); + delete listView->takeItem(2); + // list: Oslo, Helsinki, Munich + + QAccessibleInterface *cellMunich3 = table2->cellAt(2,0); + QCOMPARE(cell4, cellMunich3); + QCOMPARE(axidMunich, QAccessible::uniqueId(cellMunich3)); + + delete listView; } QTestAccessibility::clearEvents(); @@ -2616,29 +2576,24 @@ void tst_QAccessibility::treeTest() // header and 2 rows (the others are not expanded, thus not visible) QCOMPARE(iface->childCount(), 6); - QAccessibleInterface *header1 = 0; - header1 = iface->child(0); + QAccessibleInterface *header1 = iface->child(0); QVERIFY(header1); QCOMPARE(iface->indexOfChild(header1), 0); QCOMPARE(header1->text(QAccessible::Name), QString("Artist")); QCOMPARE(header1->role(), QAccessible::ColumnHeader); - delete header1; - QAccessibleInterface *child1 = 0; - child1 = iface->child(2); + QAccessibleInterface *child1 = iface->child(2); QVERIFY(child1); QCOMPARE(iface->indexOfChild(child1), 2); QCOMPARE(child1->text(QAccessible::Name), QString("Spain")); QCOMPARE(child1->role(), QAccessible::TreeItem); QVERIFY(!(child1->state().expanded)); - delete child1; QAccessibleInterface *child2 = 0; child2 = iface->child(4); QVERIFY(child2); QCOMPARE(iface->indexOfChild(child2), 4); QCOMPARE(child2->text(QAccessible::Name), QString("Austria")); - delete child2; QTestAccessibility::clearEvents(); @@ -2660,8 +2615,6 @@ void tst_QAccessibility::treeTest() QCOMPARE(iface->indexOfChild(cell2), 4); QVERIFY(!(cell2->state().expanded)); QCOMPARE(table2->columnDescription(1), QString("Work")); - delete cell2; - delete cell1; treeView->expandAll(); @@ -2687,14 +2640,13 @@ void tst_QAccessibility::treeTest() QModelIndex index = treeView->model()->index(0, 0, treeView->model()->index(1, 0)); pos += treeView->visualRect(index).center(); pos += QPoint(0, treeView->header()->height()); - QAIPtr childAt2(iface->childAt(pos.x(), pos.y())); + QAccessibleInterface *childAt2(iface->childAt(pos.x(), pos.y())); QVERIFY(childAt2); QCOMPARE(childAt2->text(QAccessible::Name), QString("Klimt")); QCOMPARE(table2->columnDescription(0), QString("Artist")); QCOMPARE(table2->columnDescription(1), QString("Work")); - delete iface; delete treeView; QTestAccessibility::clearEvents(); } @@ -2726,36 +2678,36 @@ void tst_QAccessibility::tableTest() tableView->show(); QTest::qWaitForWindowExposed(tableView); - QAIPtr iface = QAIPtr(QAccessible::queryAccessibleInterface(tableView)); - QCOMPARE(verifyHierarchy(iface.data()), 0); + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(tableView); + QCOMPARE(verifyHierarchy(iface), 0); QCOMPARE(iface->role(), QAccessible::Table); // header and 2 rows (the others are not expanded, thus not visible) QCOMPARE(iface->childCount(), 9+3+3+1); // cell+headers+topleft button - QAIPtr cornerButton(iface->child(0)); + QAccessibleInterface *cornerButton(iface->child(0)); QVERIFY(cornerButton); - QCOMPARE(iface->indexOfChild(cornerButton.data()), 0); + QCOMPARE(iface->indexOfChild(cornerButton), 0); QCOMPARE(cornerButton->role(), QAccessible::Pane); - QAIPtr h2(iface->child(2)); + QAccessibleInterface *h2(iface->child(2)); QVERIFY(h2); - QCOMPARE(iface->indexOfChild(h2.data()), 2); + QCOMPARE(iface->indexOfChild(h2), 2); QCOMPARE(h2->text(QAccessible::Name), QString("h2")); QCOMPARE(h2->role(), QAccessible::ColumnHeader); QVERIFY(!(h2->state().expanded)); - QAIPtr v3(iface->child(12)); + QAccessibleInterface *v3(iface->child(12)); QVERIFY(v3); - QCOMPARE(iface->indexOfChild(v3.data()), 12); + QCOMPARE(iface->indexOfChild(v3), 12); QCOMPARE(v3->text(QAccessible::Name), QString("v3")); QCOMPARE(v3->role(), QAccessible::RowHeader); QVERIFY(!(v3->state().expanded)); - QAIPtr child10(iface->child(10)); + QAccessibleInterface *child10(iface->child(10)); QVERIFY(child10); - QCOMPARE(iface->indexOfChild(child10.data()), 10); + QCOMPARE(iface->indexOfChild(child10), 10); QCOMPARE(child10->text(QAccessible::Name), QString("1.1")); QAccessibleTableCellInterface *cell10Iface = child10->tableCellInterface(); QCOMPARE(cell10Iface->rowIndex(), 1); @@ -2763,11 +2715,11 @@ void tst_QAccessibility::tableTest() QPoint pos = tableView->mapToGlobal(QPoint(0,0)); pos += tableView->visualRect(tableView->model()->index(1, 1)).center(); pos += QPoint(tableView->verticalHeader()->width(), tableView->horizontalHeader()->height()); - QAIPtr childAt10(iface->childAt(pos.x(), pos.y())); + QAccessibleInterface *childAt10(iface->childAt(pos.x(), pos.y())); QCOMPARE(childAt10->text(QAccessible::Name), QString("1.1")); - QAIPtr child11(iface->child(11)); - QCOMPARE(iface->indexOfChild(child11.data()), 11); + QAccessibleInterface *child11(iface->child(11)); + QCOMPARE(iface->indexOfChild(child11), 11); QCOMPARE(child11->text(QAccessible::Name), QString("1.2")); @@ -2783,21 +2735,21 @@ void tst_QAccessibility::tableTest() QCOMPARE(cell1->text(QAccessible::Name), QString("0.0")); QCOMPARE(iface->indexOfChild(cell1), 5); - QAIPtr cell2(table2->cellAt(0,1)); + QAccessibleInterface *cell2(table2->cellAt(0,1)); QVERIFY(cell2); QCOMPARE(cell2->text(QAccessible::Name), QString("0.1")); QCOMPARE(cell2->role(), QAccessible::Cell); QCOMPARE(cell2->tableCellInterface()->rowIndex(), 0); QCOMPARE(cell2->tableCellInterface()->columnIndex(), 1); - QCOMPARE(iface->indexOfChild(cell2.data()), 6); + QCOMPARE(iface->indexOfChild(cell2), 6); - QAIPtr cell3(table2->cellAt(1,2)); + QAccessibleInterface *cell3(table2->cellAt(1,2)); QVERIFY(cell3); QCOMPARE(cell3->text(QAccessible::Name), QString("1.2")); QCOMPARE(cell3->role(), QAccessible::Cell); QCOMPARE(cell3->tableCellInterface()->rowIndex(), 1); QCOMPARE(cell3->tableCellInterface()->columnIndex(), 2); - QCOMPARE(iface->indexOfChild(cell3.data()), 11); + QCOMPARE(iface->indexOfChild(cell3), 11); QCOMPARE(table2->columnDescription(0), QString("h1")); QCOMPARE(table2->columnDescription(1), QString("h2")); @@ -2841,7 +2793,7 @@ void tst_QAccessibility::tableTest() QVERIFY(table2->isColumnSelected(1)); QVERIFY(table2->isRowSelected(1)); - QAIPtr cell4(table2->cellAt(2,2)); + QAccessibleInterface *cell4 = table2->cellAt(2,2); QVERIFY(cell1->actionInterface()); QVERIFY(cell1->tableCellInterface()); @@ -2876,8 +2828,101 @@ void tst_QAccessibility::tableTest() QVERIFY(cell1->tableCellInterface()->isSelected()); QVERIFY(!cell2->tableCellInterface()->isSelected()); + QAccessibleInterface *cell00 = table2->cellAt(0, 0); + QAccessible::Id id00 = QAccessible::uniqueId(cell00); + QVERIFY(id00); + QCOMPARE(cell00->tableCellInterface()->rowIndex(), 0); + QCOMPARE(cell00->tableCellInterface()->columnIndex(), 0); + + QAccessibleInterface *cell01 = table2->cellAt(0, 1); + + QAccessibleInterface *cell02 = table2->cellAt(0, 2); + QAccessible::Id id02 = QAccessible::uniqueId(cell02); + QVERIFY(id02); + QCOMPARE(cell02->tableCellInterface()->rowIndex(), 0); + QCOMPARE(cell02->tableCellInterface()->columnIndex(), 2); + + QAccessibleInterface *cell20 = table2->cellAt(2, 0); + QAccessible::Id id20 = QAccessible::uniqueId(cell20); + QVERIFY(id20); + QCOMPARE(cell20->tableCellInterface()->rowIndex(), 2); + QCOMPARE(cell20->tableCellInterface()->columnIndex(), 0); + + QAccessibleInterface *cell22 = table2->cellAt(2, 2); + QAccessible::Id id22 = QAccessible::uniqueId(cell22); + QVERIFY(id22); + QCOMPARE(cell22->tableCellInterface()->rowIndex(), 2); + QCOMPARE(cell22->tableCellInterface()->columnIndex(), 2); + + // modification: inserting and removing rows/columns + tableView->insertRow(2); + // Button (0) | h1 (1) | h2 (2) | h3 (3) + // v1 (4) | 0.0 (5) | 1.0 (6) | 2.0 (7) + // v2 (8) | 0.1 (9) | 1.1 (10) | 2.1 (11) + // new (12) | (13) | (14) | (15) + // v3 (16) | 0.2 (17) | 1.2 (18) | 2.2 (19) + + QAccessibleInterface *cell00_new = table2->cellAt(0, 0); + QCOMPARE(cell00, cell00_new); + QCOMPARE(cell00->tableCellInterface()->rowIndex(), 0); + QCOMPARE(cell00->tableCellInterface()->columnIndex(), 0); + + QAccessibleInterface *cell02_new = table2->cellAt(0, 2); + QCOMPARE(cell02, cell02_new); + QCOMPARE(cell02_new->tableCellInterface()->rowIndex(), 0); + QCOMPARE(cell02_new->tableCellInterface()->columnIndex(), 2); + + QAccessibleInterface *cell20_new = table2->cellAt(2, 0); + QAccessibleInterface *cell30_new = table2->cellAt(3, 0); + QAccessible::Id id20_new = QAccessible::uniqueId(cell20_new); + QVERIFY(id20_new != id20); + QAccessible::Id id30_new = QAccessible::uniqueId(cell30_new); + QCOMPARE(id20, id30_new); + QCOMPARE(cell20->tableCellInterface()->rowIndex(), 3); + QCOMPARE(cell20->tableCellInterface()->columnIndex(), 0); + + QAccessibleInterface *cell22_new = table2->cellAt(2, 2); + QAccessibleInterface *cell32_new = table2->cellAt(3, 2); + QAccessible::Id id22_new = QAccessible::uniqueId(cell22_new); + QVERIFY(id22_new != id22); + QAccessible::Id id32_new = QAccessible::uniqueId(cell32_new); + QCOMPARE(id22, id32_new); + QCOMPARE(cell32_new->tableCellInterface()->rowIndex(), 3); + QCOMPARE(cell32_new->tableCellInterface()->columnIndex(), 2); + + + QVERIFY(table2->cellAt(0, 0) == cell1); + + tableView->insertColumn(2); + // Button (0) | h1 (1) | h2 (2) | (3) | h3 (4) + // v1 (5) | 0.0 (6) | 1.0 (7) | (8) | 2.0 (9) + // v2 (10) | 0.1 (11) | 1.1 (12) | (13) | 2.1 (14) + // new (15) | (16) | (17) | (18) | (19) + // v3 (20) | 0.2 (21) | 1.2 (22) | (23) | 2.2 (24) + + cell00_new = table2->cellAt(0, 0); + QCOMPARE(cell00, cell00_new); + QCOMPARE(cell00->tableCellInterface()->rowIndex(), 0); + QCOMPARE(cell00->tableCellInterface()->columnIndex(), 0); + + QAccessibleInterface *cell01_new = table2->cellAt(0, 1); + QCOMPARE(cell01, cell01_new); + QCOMPARE(cell01_new->tableCellInterface()->rowIndex(), 0); + QCOMPARE(cell01_new->tableCellInterface()->columnIndex(), 1); + + QAccessibleInterface *cell03_new = table2->cellAt(0, 3); + QVERIFY(cell03_new); + QCOMPARE(cell03_new->tableCellInterface()->rowIndex(), 0); + QCOMPARE(cell03_new->tableCellInterface()->columnIndex(), 3); + QCOMPARE(iface->indexOfChild(cell03_new), 9); + QCOMPARE(cell03_new, cell02); + + cell30_new = table2->cellAt(3, 0); + QCOMPARE(cell30_new, cell20); + QCOMPARE(iface->indexOfChild(cell30_new), 21); delete tableView; + QVERIFY(!QAccessible::accessibleInterface(id00)); QTestAccessibility::clearEvents(); } @@ -2954,9 +2999,7 @@ void tst_QAccessibility::calendarWidgetTest() // In order for geometric navigation to work they must share the same parent QCOMPARE(navigationBarInterface->parent()->object(), calendarViewInterface->parent()->object()); QVERIFY(navigationBarInterface->rect().bottom() < calendarViewInterface->rect().top()); - delete calendarViewInterface; calendarViewInterface = 0; - delete navigationBarInterface; navigationBarInterface = 0; } @@ -3001,8 +3044,6 @@ void tst_QAccessibility::dockWidgetTest() if (accMainWindow->role() == QAccessible::Window) { if (accDock1 && qobject_cast(accDock1->object()) == dock1) { break; - } else { - delete accDock1; } } } @@ -3012,7 +3053,6 @@ void tst_QAccessibility::dockWidgetTest() QAccessibleInterface *dock1TitleBar = accDock1->child(0); QCOMPARE(dock1TitleBar->role(), QAccessible::TitleBar); QVERIFY(accDock1->rect().contains(dock1TitleBar->rect())); - delete dock1TitleBar; QPoint globalPos = dock1->mapToGlobal(QPoint(0,0)); globalPos.rx()+=5; //### query style @@ -3020,7 +3060,6 @@ void tst_QAccessibility::dockWidgetTest() QAccessibleInterface *childAt = accDock1->childAt(globalPos.x(), globalPos.y()); //### QCOMPARE(childAt->role(), QAccessible::TitleBar); int index = accDock1->indexOfChild(childAt); - delete childAt; QAccessibleInterface *accTitleBar = accDock1->child(index); QCOMPARE(accTitleBar->role(), QAccessible::TitleBar); @@ -3030,9 +3069,6 @@ void tst_QAccessibility::dockWidgetTest() QVERIFY(acc); QCOMPARE(acc->role(), QAccessible::Window); - - delete accTitleBar; - delete accDock1; delete pb1; delete pb2; delete dock1; @@ -3082,7 +3118,6 @@ void tst_QAccessibility::comboBoxTest() iface->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction()); QTRY_VERIFY(combo.view()->isVisible()); - delete iface; } { // editable combobox @@ -3102,10 +3137,6 @@ void tst_QAccessibility::comboBoxTest() QCOMPARE(listIface->role(), QAccessible::List); QAccessibleInterface *editIface = iface->child(1); QCOMPARE(editIface->role(), QAccessible::EditableText); - - delete listIface; - delete editIface; - delete iface; } QTestAccessibility::clearEvents(); @@ -3128,7 +3159,6 @@ void tst_QAccessibility::labelTest() QCOMPARE(acc_label->text(QAccessible::Name), text); - delete acc_label; delete label; QTestAccessibility::clearEvents(); @@ -3150,8 +3180,6 @@ void tst_QAccessibility::labelTest() const QPoint labelPos = imageLabel.mapToGlobal(QPoint(0,0)); QCOMPARE(imageInterface->imagePosition().topLeft(), labelPos); - delete acc_label; - QTestAccessibility::clearEvents(); } @@ -3421,8 +3449,9 @@ void tst_QAccessibility::bridgeTest() IAccessible *accTableCell = 0; hr = ia2Table->get_cellAt(1, 2, (IUnknown**)&accTableCell); - IAccessibleTableCell *ia2TableCell = (IAccessibleTableCell *)queryIA2(accTableCell, IID_IAccessibleTableCell); QVERIFY(SUCCEEDED(hr)); + QVERIFY(accTableCell); + IAccessibleTableCell *ia2TableCell = (IAccessibleTableCell *)queryIA2(accTableCell, IID_IAccessibleTableCell); QVERIFY(ia2TableCell); LONG index; ia2TableCell->get_rowIndex(&index); -- cgit v1.2.3 From 406c8ef6e67da5505c7404a2517a8b4204d7c38a Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Sat, 30 Mar 2013 19:55:25 +0100 Subject: Move the dbmstype to QSqlDriverPrivate so it can be used for all drivers By moving it to QSqlDriverPrivate we make it easier to check what database is actually connected which is particularly useful for the autotests. Change-Id: I54d1c2c998919c1d54efb1b6ac9303070ece54aa Reviewed-by: Mark Brand --- tests/auto/sql/kernel/qsql/qsql.pro | 2 +- tests/auto/sql/kernel/qsqldatabase/qsqldatabase.pro | 2 +- tests/auto/sql/kernel/qsqldatabase/tst_databases.h | 18 +++++++++--------- tests/auto/sql/kernel/qsqldriver/qsqldriver.pro | 2 +- tests/auto/sql/kernel/qsqlquery/qsqlquery.pro | 2 +- tests/auto/sql/kernel/qsqlthread/qsqlthread.pro | 2 +- .../auto/sql/models/qsqlquerymodel/qsqlquerymodel.pro | 2 +- .../qsqlrelationaltablemodel.pro | 2 +- tests/benchmarks/sql/kernel/qsqlquery/qsqlquery.pro | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) (limited to 'tests') diff --git a/tests/auto/sql/kernel/qsql/qsql.pro b/tests/auto/sql/kernel/qsql/qsql.pro index c890352d45..0735986438 100644 --- a/tests/auto/sql/kernel/qsql/qsql.pro +++ b/tests/auto/sql/kernel/qsql/qsql.pro @@ -3,7 +3,7 @@ CONFIG += parallel_test TARGET = tst_qsql SOURCES += tst_qsql.cpp -QT += sql sql-private gui testlib +QT += sql sql-private gui testlib core-private wince*: { DEPLOYMENT_PLUGIN += qsqlite diff --git a/tests/auto/sql/kernel/qsqldatabase/qsqldatabase.pro b/tests/auto/sql/kernel/qsqldatabase/qsqldatabase.pro index 89dc7a5c7c..d562e47c55 100644 --- a/tests/auto/sql/kernel/qsqldatabase/qsqldatabase.pro +++ b/tests/auto/sql/kernel/qsqldatabase/qsqldatabase.pro @@ -2,7 +2,7 @@ CONFIG += testcase TARGET = tst_qsqldatabase SOURCES += tst_qsqldatabase.cpp -QT = core sql testlib +QT = core sql testlib core-private sql-private win32: { !wince*: LIBS += -lws2_32 diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h index 9d3523576f..0eb3ba8c22 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_databases.h +++ b/tests/auto/sql/kernel/qsqldatabase/tst_databases.h @@ -52,7 +52,7 @@ #include #include #include - +#include #include #if defined (Q_OS_WIN) || defined (Q_OS_WIN32) @@ -510,11 +510,8 @@ public: static bool isSqlServer( QSqlDatabase db ) { - return db.databaseName().contains( "sql server", Qt::CaseInsensitive ) - || db.databaseName().contains( "sqlserver", Qt::CaseInsensitive ) - || db.databaseName().contains( "sql native client", Qt::CaseInsensitive ) - || db.databaseName().contains( "bq-winserv", Qt::CaseInsensitive ) - || db.hostName().contains( "bq-winserv", Qt::CaseInsensitive ); + QSqlDriverPrivate *d = static_cast(QObjectPrivate::get(db.driver())); + return d->dbmsType == QSqlDriverPrivate::MSSqlServer; } static bool isMSAccess( QSqlDatabase db ) @@ -524,16 +521,19 @@ public: static bool isPostgreSQL( QSqlDatabase db ) { - return db.driverName().startsWith("QPSQL") || (db.driverName().startsWith("QODBC") && ( db.databaseName().contains("PostgreSQL", Qt::CaseInsensitive) || db.databaseName().contains("pgsql", Qt::CaseInsensitive) ) ); + QSqlDriverPrivate *d = static_cast(QObjectPrivate::get(db.driver())); + return d->dbmsType == QSqlDriverPrivate::PostgreSQL; } static bool isMySQL( QSqlDatabase db ) { - return db.driverName().startsWith("QMYSQL") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("MySQL", Qt::CaseInsensitive) ); + QSqlDriverPrivate *d = static_cast(QObjectPrivate::get(db.driver())); + return d->dbmsType == QSqlDriverPrivate::MySqlServer; } static bool isDB2( QSqlDatabase db ) { - return db.driverName().startsWith("QDB2") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("db2", Qt::CaseInsensitive) ); + QSqlDriverPrivate *d = static_cast(QObjectPrivate::get(db.driver())); + return d->dbmsType == QSqlDriverPrivate::DB2; } // -1 on fail, else Oracle version diff --git a/tests/auto/sql/kernel/qsqldriver/qsqldriver.pro b/tests/auto/sql/kernel/qsqldriver/qsqldriver.pro index ef7bb70a94..abdc157c7f 100644 --- a/tests/auto/sql/kernel/qsqldriver/qsqldriver.pro +++ b/tests/auto/sql/kernel/qsqldriver/qsqldriver.pro @@ -3,7 +3,7 @@ CONFIG += parallel_test TARGET = tst_qsqldriver SOURCES += tst_qsqldriver.cpp -QT = core sql testlib +QT = core sql testlib core-private sql-private wince*: { plugFiles.files = ../../../plugins/sqldrivers diff --git a/tests/auto/sql/kernel/qsqlquery/qsqlquery.pro b/tests/auto/sql/kernel/qsqlquery/qsqlquery.pro index c1e2a7ebb1..360d874f1a 100644 --- a/tests/auto/sql/kernel/qsqlquery/qsqlquery.pro +++ b/tests/auto/sql/kernel/qsqlquery/qsqlquery.pro @@ -3,7 +3,7 @@ CONFIG += testcase SOURCES += tst_qsqlquery.cpp -QT = core sql testlib +QT = core sql testlib core-private sql-private !wince*:win32:LIBS += -lws2_32 diff --git a/tests/auto/sql/kernel/qsqlthread/qsqlthread.pro b/tests/auto/sql/kernel/qsqlthread/qsqlthread.pro index 73247545ce..3249309bf4 100644 --- a/tests/auto/sql/kernel/qsqlthread/qsqlthread.pro +++ b/tests/auto/sql/kernel/qsqlthread/qsqlthread.pro @@ -2,7 +2,7 @@ CONFIG += testcase TARGET = tst_qsqlthread SOURCES += tst_qsqlthread.cpp -QT = core sql testlib +QT = core sql testlib core-private sql-private wince*: { diff --git a/tests/auto/sql/models/qsqlquerymodel/qsqlquerymodel.pro b/tests/auto/sql/models/qsqlquerymodel/qsqlquerymodel.pro index cbbd1d6eb7..40ec56d473 100644 --- a/tests/auto/sql/models/qsqlquerymodel/qsqlquerymodel.pro +++ b/tests/auto/sql/models/qsqlquerymodel/qsqlquerymodel.pro @@ -2,7 +2,7 @@ CONFIG += testcase TARGET = tst_qsqlquerymodel SOURCES += tst_qsqlquerymodel.cpp -QT += widgets sql testlib +QT += widgets sql testlib core-private sql-private wince*: { DEPLOYMENT_PLUGIN += qsqlite diff --git a/tests/auto/sql/models/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro b/tests/auto/sql/models/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro index 117ad5cbf6..0d7318a5c9 100644 --- a/tests/auto/sql/models/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro +++ b/tests/auto/sql/models/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro @@ -2,7 +2,7 @@ CONFIG += testcase TARGET = tst_qsqlrelationaltablemodel SOURCES += tst_qsqlrelationaltablemodel.cpp -QT = core sql testlib +QT = core sql testlib core-private sql-private wince*: { plugFiles.files = ../../../plugins/sqldrivers diff --git a/tests/benchmarks/sql/kernel/qsqlquery/qsqlquery.pro b/tests/benchmarks/sql/kernel/qsqlquery/qsqlquery.pro index 5c17220190..bfea404980 100644 --- a/tests/benchmarks/sql/kernel/qsqlquery/qsqlquery.pro +++ b/tests/benchmarks/sql/kernel/qsqlquery/qsqlquery.pro @@ -2,6 +2,6 @@ TARGET = tst_bench_qsqlquery SOURCES += main.cpp -QT = core sql testlib +QT = core sql testlib core-private sql-private win32: LIBS += -lws2_32 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 -- cgit v1.2.3 From 448c3e85dddbfc5c101aceeeceb8584a3d41c913 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 21 Mar 2013 21:09:42 +0200 Subject: Fix Qt tests for Android. Change-Id: I53856056a00684a9a37596a74b79f46d3b47331f Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/android/AndroidManifest.xml | 2 +- tests/auto/android/res/values/libs.xml | 28 ++++++----- tests/auto/android/runtests.pl | 26 ++++++---- .../src/org/qtproject/qt5/android/QtActivity.java | 7 +-- .../src/org/qtproject/qt5/android/QtNative.java | 55 ++++++++++++++++++++-- 5 files changed, 87 insertions(+), 31 deletions(-) (limited to 'tests') diff --git a/tests/auto/android/AndroidManifest.xml b/tests/auto/android/AndroidManifest.xml index 32e2b88d66..bd1e0afc68 100644 --- a/tests/auto/android/AndroidManifest.xml +++ b/tests/auto/android/AndroidManifest.xml @@ -4,7 +4,7 @@ android:versionCode="1" android:versionName="1.0"> - + diff --git a/tests/auto/android/res/values/libs.xml b/tests/auto/android/res/values/libs.xml index 7f2858e554..43f1d4aff4 100644 --- a/tests/auto/android/res/values/libs.xml +++ b/tests/auto/android/res/values/libs.xml @@ -1,19 +1,21 @@ - QtCore - QtGui - QtTest - QtOpenGL - QtNetwork - QtScript - QtSql - QtXml - QtScriptTools - QtSvg - QtXmlPatterns - QtDeclarative - QtWebKit + gnustl_shared + Qt5Core + Qt5Gui + Qt5Widgets + Qt5Test + Qt5OpenGL + Qt5Network + Qt5Script + Qt5Sql + Qt5Xml + Qt5ScriptTools + Qt5Svg + Qt5XmlPatterns + Qt5Declarative + Qt5WebKit diff --git a/tests/auto/android/runtests.pl b/tests/auto/android/runtests.pl index 70a242f29f..7bb6833859 100755 --- a/tests/auto/android/runtests.pl +++ b/tests/auto/android/runtests.pl @@ -1,8 +1,8 @@ #!/usr/bin/perl -w ############################################################################# ## +## Copyright (C) 2012-2013 BogDan Vatra ## Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -## Copyright (C) 2012 BogDan Vatra ## Contact: http://www.qt-project.org/legal ## ## This file is part of the test suite of the Qt Toolkit. @@ -61,7 +61,8 @@ my $help = 0; my $make_clean = 0; my $deploy_qt = 0; my $time_out=400; -my $android_sdk_dir = "$ENV{'HOME'}/NecessitasQtSDK/android-sdk"; +my $android_sdk_dir = "$ENV{'ANDROID_SDK_ROOT'}"; +my $android_ndk_dir = "$ENV{'ANDROID_NDK_ROOT'}"; my $ant_tool = `which ant`; chomp $ant_tool; my $strip_tool=""; @@ -74,6 +75,7 @@ GetOptions('h|help' => \$help , 'd|deploy' => \$deploy_qt , 'j|jobs=i' => \$jobs , 'sdk=s' => \$android_sdk_dir + , 'ndk=s' => \$android_ndk_dir , 'ant=s' => \$ant_tool , 'strip=s' => \$strip_tool , 'readelf=s' => \$readelf_tool @@ -87,8 +89,8 @@ system("$adb_tool devices") == 0 or die "No device found, please plug/start at l $device_serial = "-s $device_serial" if ($device_serial); $testsubset="/$testsubset" if ($testsubset); -$strip_tool="$ENV{'HOME'}/NecessitasQtSDK/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-strip" unless($strip_tool); -$readelf_tool="$ENV{'HOME'}/NecessitasQtSDK/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-readelf" unless($readelf_tool); +$strip_tool="$android_ndk_dir/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86/bin/arm-linux-androideabi-strip" unless($strip_tool); +$readelf_tool="$android_ndk_dir/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86/bin/arm-linux-androideabi-readelf" unless($readelf_tool); $readelf_tool="$readelf_tool -d -w "; sub dir @@ -141,7 +143,7 @@ sub waitForProcess return 0; } -my $src_dir_qt=abs_path(dirname($0)."/.."); +my $src_dir_qt=abs_path(dirname($0)."/../../.."); my $quadruplor_dir="$src_dir_qt/tests/auto/android"; my $qmake_path="$src_dir_qt/bin/qmake"; my $tests_dir="$src_dir_qt/tests$testsubset"; @@ -232,11 +234,12 @@ if ($deploy_qt) } system("cp -a plugins $temp_dir"); system("cp -a imports $temp_dir"); + system("cp -a qml $temp_dir"); pushd($temp_dir); system("find -name *.so | xargs $strip_tool --strip-unneeded"); popd; - system("$adb_tool $device_serial shell rm -r /data/local/qt"); # remove old qt libs - system("$adb_tool $device_serial push $temp_dir /data/local/qt"); # copy newer qt libs + system("$adb_tool $device_serial shell rm -r /data/local/tmp/qt"); # remove old qt libs + system("$adb_tool $device_serial push $temp_dir /data/local/tmp/qt"); # copy newer qt libs popd; } @@ -245,6 +248,7 @@ reinstallQuadruplor; ########### build qt tests and benchmarks ########### pushd($tests_dir); +print "Building $tests_dir \n"; system("make distclean") if ($make_clean); system("$qmake_path CONFIG-=QTDIR_build -r") == 0 or die "Can't run qmake\n"; #exec qmake system("make -j$jobs") == 0 or warn "Can't build all tests\n"; #exec make @@ -273,12 +277,12 @@ foreach (split("\n",$testsFiles)) { if (needsOpenGl("$temp_dir/libtst_$application.so")) { - startTest("/data/local/qt/plugins/platforms/android/libandroidGL-$sdk_api.so", "/data/data/$packageName/app_files/libtst_$application.so", 1 + startTest("/data/local/tmp/qt/plugins/platforms/android/libqtforandroidGL.so", "/data/data/$packageName/app_files/libtst_$application.so", 1 , "$output_name.xml") or warn "Can't run $application ...\n"; } else { - startTest("/data/local/qt/plugins/platforms/android/libandroid-$sdk_api.so", "/data/data/$packageName/app_files/libtst_$application.so", 0 + startTest("/data/local/tmp/qt/plugins/platforms/android/libqtforandroid.so", "/data/data/$packageName/app_files/libtst_$application.so", 0 , "$output_name.xml") or warn "Can't run $application stopping tests ...\n"; } } @@ -329,6 +333,10 @@ Make jobs when building tests. Android SDK path. +=item B<--ndk = ndk_path> + +Android NDK path. + =item B<--ant = ant_tool_path> Ant tool path. diff --git a/tests/auto/android/src/org/qtproject/qt5/android/QtActivity.java b/tests/auto/android/src/org/qtproject/qt5/android/QtActivity.java index ae4ca3c30a..6242f55488 100644 --- a/tests/auto/android/src/org/qtproject/qt5/android/QtActivity.java +++ b/tests/auto/android/src/org/qtproject/qt5/android/QtActivity.java @@ -90,7 +90,7 @@ public class QtActivity extends Activity { String qtLibs[] = getResources().getStringArray(R.array.qt_libs); ArrayList libraryList = new ArrayList(); for (int i = 0; i < qtLibs.length; i++) - libraryList.add("/data/local/qt/lib/lib" + qtLibs[i] + ".so"); + libraryList.add("/data/local/tmp/qt/lib/lib" + qtLibs[i] + ".so"); String mainLib = null; String nativeLibDir = null; @@ -124,8 +124,9 @@ public class QtActivity extends Activity { } String[] libs = new String[libraryList.size()]; libs = libraryList.toArray(libs); - loadQtLibs(libs, "QML_IMPORT_PATH=/data/local/qt/imports\tQT_PLUGIN_PATH=/data/local/qt/plugins", - "-xml\t-silent\t-o\toutput.xml", mainLib, nativeLibDir); + loadQtLibs(libs + ,"QT_QPA_EGLFS_HIDECURSOR=1\tQML2_IMPORT_PATH=/data/local/tmp/qt/qml\tQML_IMPORT_PATH=/data/local/tmp/qt/imports\tQT_PLUGIN_PATH=/data/local/tmp/qt/plugins" + , "-xml\t-silent\t-o\toutput.xml", mainLib, nativeLibDir); } catch (Exception e) { Log.e(QtNative.QtTAG, "Can't create main activity", e); } diff --git a/tests/auto/android/src/org/qtproject/qt5/android/QtNative.java b/tests/auto/android/src/org/qtproject/qt5/android/QtNative.java index 8faeabe5b0..d9995e3178 100644 --- a/tests/auto/android/src/org/qtproject/qt5/android/QtNative.java +++ b/tests/auto/android/src/org/qtproject/qt5/android/QtNative.java @@ -34,6 +34,7 @@ import android.app.Application; import android.content.Intent; import android.net.Uri; import android.util.Log; +import android.view.ContextMenu; import android.view.Menu; import android.view.MotionEvent; @@ -294,6 +295,9 @@ public class QtNative extends Application } } + private static void updateSelection(final int selStart, final int selEnd, final int candidatesStart, final int candidatesEnd) + { + } private static void showSoftwareKeyboard(final int x, final int y , final int width, final int height @@ -327,6 +331,11 @@ public class QtNative extends Application }); } + private static boolean isSoftwareKeyboardVisible() + { + return false; + } + private static void setFullScreen(final boolean fullScreen) { runAction(new Runnable() { @@ -338,10 +347,41 @@ public class QtNative extends Application }); } + private static void registerClipboardManager() + { + } + + private static void setClipboardText(String text) + { + } + + private static boolean hasClipboardText() + { + return false; + } + + private static String getClipboardText() + { + return "Qt"; + } + + private static void openContextMenu() + { + } + + private static void closeContextMenu() + { + } + + private static void resetOptionsMenu() + { + } + // screen methods public static native void setDisplayMetrics(int screenWidthPixels, int screenHeightPixels, int desktopWidthPixels, int desktopHeightPixels, double XDpi, double YDpi); + public static native void handleOrientationChanged(int newOrientation); // screen methods private static void showOptionsMenu() @@ -395,6 +435,7 @@ public class QtNative extends Application public static native void touchBegin(int winId); public static native void touchAdd(int winId, int pointerId, int action, boolean primary, int x, int y, float size, float pressure); public static native void touchEnd(int winId, int action); + public static native void longPress(int winId, int x, int y); // pointer methods // keyboard methods @@ -413,9 +454,13 @@ public class QtNative extends Application public static native void updateWindow(); // window methods - // options menu methods - public static native void createOptionsMenu(Menu menu); - public static native boolean prepareOptionsMenu(Menu menu); - public static native boolean optionsItemSelected(int groupId, int itemId); - // options menu methods + // menu methods + public static native boolean onPrepareOptionsMenu(Menu menu); + public static native boolean onOptionsItemSelected(int itemId, boolean checked); + public static native void onOptionsMenuClosed(Menu menu); + + public static native void onCreateContextMenu(ContextMenu menu); + public static native boolean onContextItemSelected(int itemId, boolean checked); + public static native void onContextMenuClosed(Menu menu); + // menu methods } -- cgit v1.2.3