summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-02-10 08:26:14 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-02-10 08:26:14 (GMT)
commit3e7f05c1a07441a4b0e9ade893c519a050e5b8de (patch)
treedb54af72e0e8f241a8c01ae34bfa9124299b5c24 /tests/auto
parentf57a2756ebfb48c2fad94c0c319fa181d2af4dfd (diff)
parent4935ec52fc07d4aaa7ae594cfe9986e25ca62dcb (diff)
downloadQt-3e7f05c1a07441a4b0e9ade893c519a050e5b8de.zip
Qt-3e7f05c1a07441a4b0e9ade893c519a050e5b8de.tar.gz
Qt-3e7f05c1a07441a4b0e9ade893c519a050e5b8de.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2: (ODBC) Use wchar_t instead of assuming 2 bytes. Fixed some global QIcon/QPixmap instances that leaked handles on X11. Speed up QListView test QListView: fix crash when hiding many of the lasts item in a QListView Fixed warnings and crash when painting graphics effects outside scene. Stabilize QLineEdit test on X11 (sqlite) Allow shared cache mode Make generate uid3 (symbian) work on 64 bit host platform. Updated the docs for QPainter::begin/endNativePainting() Compile fix for network benchmarks. Add a pixmap modification hook to blur pixmap filter cache Delete benchmark examples (qtestlib-simple and qtwidgets). Restructure tests/benchmarks directory. Fixed QImagReader::setAutoDetectImageFormat() to work with plugins. QLineEdit: regression: read-only line edits would eat shortcuts. QGraphicsItem: Do not crash at exit if there is static QGraphicsItem. Make QTextCodec reentrant. Fixed bug where GL widget was not fully updated on Vista.
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp2
-rw-r--r--tests/auto/qimagereader/tst_qimagereader.cpp29
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp28
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp84
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp20
-rw-r--r--tests/auto/qtextcodec/tst_qtextcodec.cpp46
6 files changed, 170 insertions, 39 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 7b54a3b..7c1b97e 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -90,6 +90,8 @@ Q_DECLARE_METATYPE(QRectF)
#define COMPARE_REGIONS QTRY_COMPARE
#endif
+static QGraphicsRectItem staticItem; //QTBUG-7629, we should not crash at exit.
+
static void sendMousePress(QGraphicsScene *scene, const QPointF &point, Qt::MouseButton button = Qt::LeftButton)
{
QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress);
diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp
index 121a8fa..99244c2 100644
--- a/tests/auto/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp
@@ -1633,6 +1633,35 @@ void tst_QImageReader::autoDetectImageFormat()
QVERIFY(reader.canRead());
QVERIFY(!reader.read().isNull());
}
+
+#ifdef QTEST_HAVE_JPEG
+ {
+ QImageReader io(prefix + "YCbCr_rgb.jpg");
+ io.setAutoDetectImageFormat(false);
+ // This should fail since no format string is given
+ QImage image;
+ QVERIFY(!io.read(&image));
+ }
+ {
+ QImageReader io(prefix + "YCbCr_rgb.jpg", "jpg");
+ io.setAutoDetectImageFormat(false);
+ QImage image;
+ QVERIFY(io.read(&image));
+ }
+#endif
+ {
+ QImageReader io(prefix + "tst7.png");
+ io.setAutoDetectImageFormat(false);
+ // This should fail since no format string is given
+ QImage image;
+ QVERIFY(!io.read(&image));
+ }
+ {
+ QImageReader io(prefix + "tst7.png", "png");
+ io.setAutoDetectImageFormat(false);
+ QImage image;
+ QVERIFY(io.read(&image));
+ }
}
void tst_QImageReader::fileNameProbing()
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index 7283916..ca84b38 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -271,6 +271,7 @@ private slots:
void taskQTBUG_4401_enterKeyClearsPassword();
void taskQTBUG_4679_moveToStartEndOfBlock();
void taskQTBUG_4679_selectToStartEndOfBlock();
+ void taskQTBUG_7395_readOnlyShortcut();
protected slots:
#ifdef QT3_SUPPORT
@@ -3454,10 +3455,8 @@ void tst_QLineEdit::task210502_caseInsensitiveInlineCompletion()
completer.setCompletionMode(QCompleter::InlineCompletion);
lineEdit.setCompleter(&completer);
lineEdit.show();
-#ifdef Q_WS_X11
- // to be safe and avoid failing setFocus with window managers
- qt_x11_wait_for_window_manager(&lineEdit);
-#endif
+ QTest::qWaitForWindowShown(&lineEdit);
+ QApplication::setActiveWindow(&lineEdit);
lineEdit.setFocus();
QTRY_VERIFY(lineEdit.hasFocus());
QTest::keyPress(&lineEdit, 'a');
@@ -3638,5 +3637,26 @@ void tst_QLineEdit::taskQTBUG_4679_selectToStartEndOfBlock()
#endif // Q_OS_MAC
}
+void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut()
+{
+ //ReadOnly QLineEdit should not intercept shortcut.
+ QLineEdit le;
+ le.setReadOnly(true);
+
+ QAction action(QString::fromLatin1("hello"), &le);
+ action.setShortcut(QString::fromLatin1("p"));
+ QSignalSpy spy(&action, SIGNAL(triggered()));
+ le.addAction(&action);
+
+ le.show();
+ QTest::qWaitForWindowShown(&le);
+ QApplication::setActiveWindow(&le);
+ le.setFocus();
+ QTRY_VERIFY(le.hasFocus());
+
+ QTest::keyClick(0, Qt::Key_P);
+ QCOMPARE(spy.count(), 1);
+}
+
QTEST_MAIN(tst_QLineEdit)
#include "tst_qlineedit.moc"
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index 7109213..2c31d8b 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -606,9 +606,8 @@ void tst_QListView::indexAt()
view2.setWrapping(true);
// We really want to make sure it is shown, because the layout won't be known until it is shown
view2.show();
- for (int i = 0; i < 5 && !view2.m_shown; ++i) {
- QTest::qWait(500);
- }
+ QTest::qWaitForWindowShown(&view2);
+ QTRY_VERIFY(view2.m_shown);
QVERIFY(view2.m_index.isValid());
QVERIFY(view2.m_index.row() != 0);
@@ -760,7 +759,8 @@ void tst_QListView::hideFirstRow()
view.setUniformItemSizes(true);
view.setRowHidden(0,true);
view.show();
- QTest::qWait(100);
+ QTest::qWaitForWindowShown(&view);
+ QTest::qWait(10);
}
void tst_QListView::batchedMode()
@@ -778,10 +778,9 @@ void tst_QListView::batchedMode()
view.setBatchSize(2);
view.resize(200,400);
view.show();
+ QTest::qWaitForWindowShown(&view);
-#if !defined(Q_OS_WINCE)
- QTest::qWait(100);
-#else
+#if defined(Q_OS_WINCE)
QTest::qWait(2000);
#endif
QBitArray ba;
@@ -1203,9 +1202,9 @@ void tst_QListView::scrollTo()
//we click the item
QPoint p = lv.visualRect(index).center();
QTest::mouseClick(lv.viewport(), Qt::LeftButton, Qt::NoModifier, p);
- //let's wait 1 second because the scrolling is delayed
- QTest::qWait(1000);
- QCOMPARE(lv.visualRect(index).y(),0);
+ //let's wait because the scrolling is delayed
+ QTest::qWait(QApplication::doubleClickInterval() + 150);
+ QTRY_COMPARE(lv.visualRect(index).y(),0);
//we scroll down. As the item is to tall for the view, it will disappear
QTest::keyClick(lv.viewport(), Qt::Key_Down, Qt::NoModifier);
@@ -1222,9 +1221,9 @@ void tst_QListView::scrollTo()
//we click the item
p = lv.visualRect(index).center();
QTest::mouseClick(lv.viewport(), Qt::LeftButton, Qt::NoModifier, p);
- //let's wait 1 second because the scrolling is delayed
- QTest::qWait(1000);
- QCOMPARE(lv.visualRect(index).x(),0);
+ //let's wait because the scrolling is delayed
+ QTest::qWait(QApplication::doubleClickInterval() + 150);
+ QTRY_COMPARE(lv.visualRect(index).x(),0);
//we scroll right. As the item is too wide for the view, it will disappear
QTest::keyClick(lv.viewport(), Qt::Key_Right, Qt::NoModifier);
@@ -1243,9 +1242,9 @@ void tst_QListView::scrollTo()
//we click the item
p = lv.visualRect(index).center();
QTest::mouseClick(lv.viewport(), Qt::LeftButton, Qt::NoModifier, p);
- //let's wait 1 second because the scrolling is delayed
- QTest::qWait(1000);
- QCOMPARE(lv.visualRect(index).y(),0);
+ //let's wait because the scrolling is delayed
+ QTest::qWait(QApplication::doubleClickInterval() + 150);
+ QTRY_COMPARE(lv.visualRect(index).y(),0);
//we scroll down. As the item is too tall for the view, it will partially disappear
QTest::keyClick(lv.viewport(), Qt::Key_Down, Qt::NoModifier);
@@ -1277,7 +1276,7 @@ void tst_QListView::scrollBarRanges()
for (int h = 30; h <= 210; ++h) {
lv.resize(250, h);
- QTest::qWait(100); // wait for the layout to be done
+ QApplication::processEvents(); // wait for the layout to be done
int visibleRowCount = lv.viewport()->size().height() / rowHeight;
int invisibleRowCount = rowCount - visibleRowCount;
QCOMPARE(lv.verticalScrollBar()->maximum(), invisibleRowCount);
@@ -1366,7 +1365,7 @@ void tst_QListView::scrollBarAsNeeded()
model.setStringList(list);
QApplication::processEvents();
- QTest::qWait(100);
+ QTest::qWait(50);
QStringList replacement;
for (i = 0; i < itemCount; ++i) {
@@ -1375,10 +1374,9 @@ void tst_QListView::scrollBarAsNeeded()
model.setStringList(replacement);
QApplication::processEvents();
- QTest::qWait(100);
- QCOMPARE(lv.horizontalScrollBar()->isVisible(), horizontalScrollBarVisible);
- QCOMPARE(lv.verticalScrollBar()->isVisible(), verticalScrollBarVisible);
+ QTRY_COMPARE(lv.horizontalScrollBar()->isVisible(), horizontalScrollBarVisible);
+ QTRY_COMPARE(lv.verticalScrollBar()->isVisible(), verticalScrollBarVisible);
}
}
@@ -1433,10 +1431,9 @@ void tst_QListView::wordWrap()
lv.setFixedSize(150, 150);
lv.show();
QApplication::processEvents();
- QTest::qWait(100);
- QCOMPARE(lv.horizontalScrollBar()->isVisible(), false);
- QCOMPARE(lv.verticalScrollBar()->isVisible(), true);
+ QTRY_COMPARE(lv.horizontalScrollBar()->isVisible(), false);
+ QTRY_COMPARE(lv.verticalScrollBar()->isVisible(), true);
}
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
@@ -1557,7 +1554,8 @@ void tst_QListView::task248430_crashWith0SizedItem()
QStringListModel model(QStringList() << QLatin1String("item1") << QString());
view.setModel(&model);
view.show();
- QTest::qWait(100);
+ QTest::qWaitForWindowShown(&view);
+ QTest::qWait(20);
}
void tst_QListView::task250446_scrollChanged()
@@ -1569,21 +1567,21 @@ void tst_QListView::task250446_scrollChanged()
QVERIFY(index.isValid());
view.setCurrentIndex(index);
view.show();
- QTest::qWait(100);
+ QTest::qWaitForWindowShown(&view);
const int scrollValue = view.verticalScrollBar()->maximum();
view.verticalScrollBar()->setValue(scrollValue);
QCOMPARE(view.verticalScrollBar()->value(), scrollValue);
QCOMPARE(view.currentIndex(), index);
view.showMinimized();
- QTest::qWait(100);
- QCOMPARE(view.verticalScrollBar()->value(), scrollValue);
- QCOMPARE(view.currentIndex(), index);
+ QTest::qWait(50);
+ QTRY_COMPARE(view.verticalScrollBar()->value(), scrollValue);
+ QTRY_COMPARE(view.currentIndex(), index);
view.showNormal();
- QTest::qWait(100);
- QCOMPARE(view.verticalScrollBar()->value(), scrollValue);
- QCOMPARE(view.currentIndex(), index);
+ QTest::qWait(50);
+ QTRY_COMPARE(view.verticalScrollBar()->value(), scrollValue);
+ QTRY_COMPARE(view.currentIndex(), index);
}
void tst_QListView::task196118_visualRegionForSelection()
@@ -1699,7 +1697,7 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes()
view.setViewMode(QListView::IconMode);
view.setModel(&model);
view.show();
- QTest::qWait(30);
+ QTest::qWaitForWindowShown(&view);
// Verfify that item sizes are non-uniform
QVERIFY(view.sizeHintForIndex(model.index(0, 0)).height() > view.sizeHintForIndex(model.index(1, 0)).height());
@@ -1729,7 +1727,7 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes()
view.setViewMode(QListView::IconMode);
view.setModel(&model);
view.show();
- QTest::qWait(30);
+ QTest::qWaitForWindowShown(&view);
// Verfify that item sizes are non-uniform
QVERIFY(view.sizeHintForIndex(model.index(0, 0)).width() > view.sizeHintForIndex(model.index(1, 0)).width());
@@ -1789,7 +1787,6 @@ void tst_QListView::task262152_setModelColumnNavigate()
view.show();
QApplication::setActiveWindow(&view);
QTest::qWaitForWindowShown(&view);
- QTest::qWait(30);
QTRY_COMPARE(static_cast<QWidget *>(&view), QApplication::activeWindow());
QTest::keyClick(&view, Qt::Key_Down);
QTest::qWait(30);
@@ -1834,6 +1831,23 @@ void tst_QListView::taskQTBUG_2233_scrollHiddenItems()
QVERIFY(index.isValid());
QCOMPARE(index.row(), 2 * i + 1);
}
+
+ //QTBUG-7929 should not crash
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ QScrollBar *bar = view.flow() == QListView::TopToBottom
+ ? view.verticalScrollBar() : view.horizontalScrollBar();
+
+ int nbVisibleItem = rowCount / 2 - bar->maximum();
+
+ bar->setValue(bar->maximum());
+ QApplication::processEvents();
+ for (int i = rowCount; i > rowCount / 2; i--) {
+ view.setRowHidden(i, true);
+ }
+ QApplication::processEvents();
+ QCOMPARE(bar->value(), bar->maximum());
+ QCOMPARE(bar->maximum(), rowCount/4 - nbVisibleItem);
}
void tst_QListView::taskQTBUG_633_changeModelData()
diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
index 5b61da2..fe084fa 100644
--- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
@@ -202,6 +202,8 @@ private slots:
void sqlStatementUseIsNull_189093_data() { generic_data(); }
void sqlStatementUseIsNull_189093();
+ void sqlite_enable_cache_mode_data() { generic_data("QSQLITE"); }
+ void sqlite_enable_cache_mode();
private:
void createTestTables(QSqlDatabase db);
@@ -2485,5 +2487,23 @@ void tst_QSqlDatabase::oci_tables()
QVERIFY(db.tables(QSql::SystemTables).contains(systemTableName.toUpper()));
}
+void tst_QSqlDatabase::sqlite_enable_cache_mode()
+{
+ QFETCH(QString, dbName);
+ if(dbName.endsWith(":memory:"))
+ QSKIP( "cache mode is meaningless for :memory: databases", SkipSingle );
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+ db.close();
+ db.setConnectOptions("QSQLITE_ENABLE_SHARED_CACHE");
+ QVERIFY_SQL(db, open());
+ QSqlDatabase db2 = QSqlDatabase::cloneDatabase(db, dbName+":cachemodeconn2");
+ db2.setConnectOptions("QSQLITE_ENABLE_SHARED_CACHE");
+ QVERIFY_SQL(db2, open());
+ QSqlQuery q(db), q2(db2);
+ QVERIFY_SQL(q, exec("select * from "+qTableName("qtest")));
+ QVERIFY_SQL(q2, exec("select * from "+qTableName("qtest")));
+}
+
QTEST_MAIN(tst_QSqlDatabase)
#include "tst_qsqldatabase.moc"
diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp
index eb348fb..65b0448 100644
--- a/tests/auto/qtextcodec/tst_qtextcodec.cpp
+++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp
@@ -47,6 +47,8 @@
#include <qtextdocument.h>
#include <time.h>
#include <qprocess.h>
+#include <QtConcurrentMap>
+#include <QThreadPool>
#ifdef Q_OS_SYMBIAN
#define SRCDIR ""
@@ -58,6 +60,9 @@ class tst_QTextCodec : public QObject
Q_OBJECT
private slots:
+
+ void threadSafety();
+
void toUnicode_data();
void toUnicode();
void codecForName_data();
@@ -1904,5 +1909,46 @@ void tst_QTextCodec::toLocal8Bit()
}
#endif
+static QByteArray loadAndConvert(const QByteArray &codecName)
+{
+ QTextCodec *c = QTextCodec::codecForName(codecName);
+ if (!c) {
+ qDebug() << "WARNING " << codecName << " not found? ";
+ return QByteArray();
+ }
+ QString str = QString::fromLatin1(codecName);
+ QByteArray b = c->fromUnicode(str);
+ c->toUnicode(b);
+ return codecName;
+}
+
+static int loadAndConvertMIB(int mib)
+{
+ QTextCodec *c = QTextCodec::codecForMib(mib);
+ if (!c) {
+ qDebug() << "WARNING " << mib << " not found? ";
+ return 0;
+ }
+ QString str = QString::number(mib);
+ QByteArray b = c->fromUnicode(str);
+ c->toUnicode(b);
+ return mib;
+}
+
+
+void tst_QTextCodec::threadSafety()
+{
+ QThreadPool::globalInstance()->setMaxThreadCount(12);
+
+ QList<QByteArray> codecList = QTextCodec::availableCodecs();
+ QFuture<QByteArray> res = QtConcurrent::mapped(codecList, loadAndConvert);
+
+ QList<int> mibList = QTextCodec::availableMibs();
+ QFuture<int> res2 = QtConcurrent::mapped(mibList, loadAndConvertMIB);
+
+ QCOMPARE(res.results(), codecList);
+ QCOMPARE(res2.results(), mibList);
+}
+
QTEST_MAIN(tst_QTextCodec)
#include "tst_qtextcodec.moc"