summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJyri Tahtela <jyri.tahtela@nokia.com>2011-05-18 07:41:09 (GMT)
committerJyri Tahtela <jyri.tahtela@nokia.com>2011-05-18 07:41:09 (GMT)
commit9cacde74f7de702689725882633073e60c0a2baa (patch)
tree330d22dadbd28b14a7d8896823d1c33597e9993e /tests/auto
parent006c8e22075112eff6230d8168d716e44a9e29d5 (diff)
parent2c07b5d2cba8d8e499bd0861eefef12d4e00d99a (diff)
downloadQt-9cacde74f7de702689725882633073e60c0a2baa.zip
Qt-9cacde74f7de702689725882633073e60c0a2baa.tar.gz
Qt-9cacde74f7de702689725882633073e60c0a2baa.tar.bz2
Merge remote-tracking branch 'qt/4.8'
Conflicts: doc/src/examples/wheel.qdoc src/gui/util/qflickgesture.cpp src/gui/util/qflickgesture_p.h src/gui/util/qscroller.cpp src/gui/util/qscroller.h src/gui/util/qscroller_p.h src/gui/util/qscrollerproperties.cpp src/gui/util/qscrollerproperties.h tests/auto/qscroller/tst_qscroller.cpp
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp40
-rw-r--r--tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp10
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/gridview1.qml1
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp3
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp5
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml1
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp13
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/data/preventContextMenu.qml22
-rw-r--r--tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp63
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/datamodel.qml1
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/pathview0.qml1
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml8
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp56
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp5
-rw-r--r--tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp14
-rw-r--r--tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp122
-rw-r--r--tests/auto/gestures/tst_gestures.cpp20
-rw-r--r--tests/auto/gui.pro3
-rw-r--r--tests/auto/modeltest/dynamictreemodel.cpp10
-rw-r--r--tests/auto/modeltest/modeltest.cpp142
-rw-r--r--tests/auto/modeltest/tst_modeltest.cpp52
-rw-r--r--tests/auto/other.pro6
-rw-r--r--tests/auto/q3listview/tst_q3listview.cpp2
-rw-r--r--tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp10
-rw-r--r--tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp57
-rw-r--r--tests/auto/qabstractxmlnodemodel/LoadingModel.cpp54
-rw-r--r--tests/auto/qaccessibility/qaccessibility.pro3
-rw-r--r--tests/auto/qaccessibility/tst_qaccessibility.cpp367
-rw-r--r--tests/auto/qalgorithms/tst_qalgorithms.cpp3
-rw-r--r--tests/auto/qatomicint/tst_qatomicint.cpp3
-rw-r--r--tests/auto/qatomicpointer/tst_qatomicpointer.cpp3
-rw-r--r--tests/auto/qbuffer/tst_qbuffer.cpp3
-rw-r--r--tests/auto/qchar/tst_qchar.cpp4
-rw-r--r--tests/auto/qcolor/tst_qcolor.cpp2
-rw-r--r--tests/auto/qcompleter/tst_qcompleter.cpp16
-rw-r--r--tests/auto/qcomplextext/tst_qcomplextext.cpp2
-rw-r--r--tests/auto/qcopchannel/testSend/main.cpp6
-rw-r--r--tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp13
-rw-r--r--tests/auto/qdbusthreading/tst_qdbusthreading.cpp2
-rw-r--r--tests/auto/qdirmodel/tst_qdirmodel.cpp6
-rw-r--r--tests/auto/qdom/tst_qdom.cpp18
-rw-r--r--tests/auto/qfile/largefile/tst_largefile.cpp8
-rw-r--r--tests/auto/qfiledialog2/tst_qfiledialog2.cpp2
-rw-r--r--tests/auto/qglyphrun/qglyphrun.pro (renamed from tests/auto/qglyphs/qglyphs.pro)4
-rw-r--r--tests/auto/qglyphrun/test.ttf (renamed from tests/auto/qglyphs/test.ttf)bin3712 -> 3712 bytes
-rw-r--r--tests/auto/qglyphrun/tst_qglyphrun.cpp (renamed from tests/auto/qglyphs/tst_qglyphs.cpp)154
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp44
-rw-r--r--tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp22
-rw-r--r--tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp33
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp2
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp2
-rw-r--r--tests/auto/qheaderview/tst_qheaderview.cpp2
-rw-r--r--tests/auto/qimage/tst_qimage.cpp8
-rw-r--r--tests/auto/qinputdialog/tst_qinputdialog.cpp18
-rw-r--r--tests/auto/qitemmodel/modelstotest.cpp35
-rw-r--r--tests/auto/qitemmodel/tst_qitemmodel.cpp12
-rw-r--r--tests/auto/qitemview/tst_qitemview.cpp90
-rw-r--r--tests/auto/qitemview/viewstotest.cpp1
-rw-r--r--tests/auto/qlibrary/tst_qlibrary.cpp2
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp4
-rw-r--r--tests/auto/qlocale/tst_qlocale.cpp4
-rw-r--r--tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/main.cpp45
-rw-r--r--tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/simple.pro5
-rw-r--r--tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/subdir.pro7
-rw-r--r--tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/subdir_via_pro_file_extra_target.pro7
-rw-r--r--tests/auto/qmake/tst_qmake.cpp14
-rw-r--r--tests/auto/qmenu/tst_qmenu.cpp2
-rw-r--r--tests/auto/qmessagebox/tst_qmessagebox.cpp49
-rw-r--r--tests/auto/qmetaobject/tst_qmetaobject.cpp14
-rw-r--r--tests/auto/qmetatype/tst_qmetatype.cpp43
-rw-r--r--tests/auto/qmutex/tst_qmutex.cpp29
-rw-r--r--tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp44
-rw-r--r--tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp28
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp27
-rw-r--r--tests/auto/qobject/signalbug.cpp9
-rw-r--r--tests/auto/qobject/tst_qobject.cpp31
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp12
-rw-r--r--tests/auto/qprocess/tst_qprocess.cpp2
-rw-r--r--tests/auto/qrawfont/tst_qrawfont.cpp52
-rw-r--r--tests/auto/qreadwritelock/tst_qreadwritelock.cpp29
-rw-r--r--tests/auto/qscriptable/tst_qscriptable.cpp27
-rw-r--r--tests/auto/qscriptclass/tst_qscriptclass.cpp6
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp5
-rw-r--r--tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp14
-rw-r--r--tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp14
-rw-r--r--tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp38
-rw-r--r--tests/auto/qscriptvaluegenerated/testgen/testgenerator.h3
-rw-r--r--tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp4
-rw-r--r--tests/auto/qscroller/qscroller.pro3
-rw-r--r--tests/auto/qscroller/tst_qscroller.cpp537
-rw-r--r--tests/auto/qsharedpointer/externaltests.cpp14
-rw-r--r--tests/auto/qsharedpointer/tst_qsharedpointer.cpp25
-rw-r--r--tests/auto/qsplitter/tst_qsplitter.cpp6
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp4
-rw-r--r--tests/auto/qsslsocket/tst_qsslsocket.cpp19
-rw-r--r--tests/auto/qstring/tst_qstring.cpp30
-rw-r--r--tests/auto/qtableview/tst_qtableview.cpp4
-rw-r--r--tests/auto/qtcpsocket/tst_qtcpsocket.cpp36
-rw-r--r--tests/auto/qtessellator/dataparser.cpp8
-rw-r--r--tests/auto/qtessellator/oldtessellator.cpp19
-rw-r--r--tests/auto/qtessellator/testtessellator.cpp4
-rw-r--r--tests/auto/qtextblock/tst_qtextblock.cpp12
-rw-r--r--tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp18
-rw-r--r--tests/auto/qtextcodec/tst_qtextcodec.cpp8
-rw-r--r--tests/auto/qtextdocument/tst_qtextdocument.cpp26
-rw-r--r--tests/auto/qtextedit/tst_qtextedit.cpp10
-rw-r--r--tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp11
-rw-r--r--tests/auto/qthread/tst_qthread.cpp2
-rw-r--r--tests/auto/qtipc/qsharedmemory/src/qsystemlock_unix.cpp3
-rw-r--r--tests/auto/qtipc/qsharedmemory/src/qsystemlock_win.cpp3
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp20
-rw-r--r--tests/auto/qvariant/tst_qvariant.cpp19
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp75
-rw-r--r--tests/auto/qwizard/tst_qwizard.cpp21
-rw-r--r--tests/auto/qxmlinputsource/tst_qxmlinputsource.cpp4
-rw-r--r--tests/auto/qxmlquery/MessageValidator.cpp5
-rw-r--r--tests/auto/qxmlquery/NetworkOverrider.h13
-rw-r--r--tests/auto/qxmlquery/PushBaseliner.h7
-rw-r--r--tests/auto/qxmlquery/tst_qxmlquery.cpp4
-rw-r--r--tests/auto/qxmlsimplereader/tst_qxmlsimplereader.cpp24
-rw-r--r--tests/auto/qxmlstream/qc14n.h37
-rw-r--r--tests/auto/qxmlstream/tst_qxmlstream.cpp20
-rw-r--r--tests/auto/selftests/alive/qtestalive.cpp7
-rw-r--r--tests/auto/xmlpatterns/tst_xmlpatterns.cpp8
-rw-r--r--tests/auto/xmlpatternsxqts/tst_suitetest.cpp2
129 files changed, 1616 insertions, 1643 deletions
diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
index 2c57e46..361d7f3 100644
--- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
+++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp
@@ -80,7 +80,7 @@ private:
void recursiveCompareObjects(const QDeclarativeDebugObjectReference &a, const QDeclarativeDebugObjectReference &b) const;
void recursiveCompareContexts(const QDeclarativeDebugContextReference &a, const QDeclarativeDebugContextReference &b) const;
void compareProperties(const QDeclarativeDebugPropertyReference &a, const QDeclarativeDebugPropertyReference &b) const;
-
+
QDeclarativeDebugConnection *m_conn;
QDeclarativeEngineDebug *m_dbg;
QDeclarativeEngine *m_engine;
@@ -134,7 +134,7 @@ QDeclarativeDebugObjectReference tst_QDeclarativeDebug::findRootObject(int conte
{
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
waitForQuery(q_engines);
-
+
if (q_engines->engines().count() == 0)
return QDeclarativeDebugObjectReference();
QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
@@ -368,7 +368,7 @@ void tst_QDeclarativeDebug::initTestCase()
for (int i=0; i<qml.count(); i++) {
QDeclarativeComponent component(m_engine);
component.setData(qml[i], QUrl::fromLocalFile(""));
- Q_ASSERT(component.isReady()); // fails if bad syntax
+ QVERIFY(component.isReady()); // fails if bad syntax
m_components << qobject_cast<QDeclarativeItem*>(component.create());
}
m_rootItem = qobject_cast<QDeclarativeItem*>(m_components.first());
@@ -382,7 +382,7 @@ void tst_QDeclarativeDebug::initTestCase()
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
bool ok = m_conn->waitForConnected();
- Q_ASSERT(ok);
+ QVERIFY(ok);
QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
m_dbg = new QDeclarativeEngineDebug(m_conn, this);
QTRY_VERIFY(m_dbg->status() == QDeclarativeEngineDebug::Enabled);
@@ -439,7 +439,7 @@ void tst_QDeclarativeDebug::watch_property()
QDeclarativeDebugPropertyReference prop = findProperty(obj.properties(), "width");
QDeclarativeDebugPropertyWatch *watch;
-
+
QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
watch = unconnected->addWatch(prop, this);
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
@@ -450,7 +450,7 @@ void tst_QDeclarativeDebug::watch_property()
QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
delete watch;
-
+
watch = m_dbg->addWatch(prop, this);
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting);
QCOMPARE(watch->objectDebugId(), obj.debugId());
@@ -482,12 +482,12 @@ void tst_QDeclarativeDebug::watch_object()
{
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
waitForQuery(q_engines);
-
- Q_ASSERT(q_engines->engines().count() > 0);
+
+ QVERIFY(q_engines->engines().count() > 0);
QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
waitForQuery(q_context);
- Q_ASSERT(q_context->rootContext().objects().count() > 0);
+ QVERIFY(q_context->rootContext().objects().count() > 0);
QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this);
waitForQuery(q_obj);
@@ -504,7 +504,7 @@ void tst_QDeclarativeDebug::watch_object()
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
delete watch;
delete unconnected;
-
+
watch = m_dbg->addWatch(QDeclarativeDebugObjectReference(), this);
QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
@@ -558,7 +558,7 @@ void tst_QDeclarativeDebug::watch_expression()
QFETCH(int, incrementCount);
int origWidth = m_rootItem->property("width").toInt();
-
+
QDeclarativeDebugObjectReference obj = findRootObject();
QDeclarativeDebugObjectExpressionWatch *watch;
@@ -568,12 +568,12 @@ void tst_QDeclarativeDebug::watch_expression()
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
delete watch;
delete unconnected;
-
+
watch = m_dbg->addWatch(QDeclarativeDebugObjectReference(), expr, this);
QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
delete watch;
-
+
watch = m_dbg->addWatch(obj, expr, this);
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting);
QCOMPARE(watch->objectDebugId(), obj.debugId());
@@ -603,7 +603,7 @@ void tst_QDeclarativeDebug::watch_expression()
delete watch;
// restore original value and verify spy doesn't get a signal since watch has been removed
- m_rootItem->setProperty("width", origWidth);
+ m_rootItem->setProperty("width", origWidth);
QTest::qWait(100);
QCOMPARE(spy.count(), expectedSpyCount);
@@ -681,7 +681,7 @@ void tst_QDeclarativeDebug::queryRootContexts()
delete q_engines;
QDeclarativeDebugRootContextQuery *q_context;
-
+
QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
q_context = unconnected->queryRootContexts(engineId, this);
QCOMPARE(q_context->state(), QDeclarativeDebugQuery::Error);
@@ -725,7 +725,7 @@ void tst_QDeclarativeDebug::queryObject()
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
waitForQuery(q_engines);
-
+
QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
waitForQuery(q_context);
QDeclarativeDebugObjectReference rootObject = q_context->rootContext().objects()[0];
@@ -806,7 +806,7 @@ void tst_QDeclarativeDebug::queryExpressionResult()
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
waitForQuery(q_engines); // check immediate deletion is ok
-
+
QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
waitForQuery(q_context);
int objectId = q_context->rootContext().objects()[0].debugId();
@@ -818,7 +818,7 @@ void tst_QDeclarativeDebug::queryExpressionResult()
QCOMPARE(q_expr->state(), QDeclarativeDebugQuery::Error);
delete q_expr;
delete unconnected;
-
+
q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
delete q_expr;
@@ -964,7 +964,7 @@ void tst_QDeclarativeDebug::tst_QDeclarativeDebugPropertyReference()
QDeclarativeDebugObjectQuery *query = m_dbg->queryObject(rootObject, this);
waitForQuery(query);
QDeclarativeDebugObjectReference obj = query->object();
- delete query;
+ delete query;
QDeclarativeDebugPropertyReference ref = findProperty(obj.properties(), "scale");
QVERIFY(ref.objectDebugId() > 0);
@@ -973,7 +973,7 @@ void tst_QDeclarativeDebug::tst_QDeclarativeDebugPropertyReference()
QVERIFY(!ref.valueTypeName().isEmpty());
QVERIFY(!ref.binding().isEmpty());
QVERIFY(ref.hasNotifySignal());
-
+
QDeclarativeDebugPropertyReference copy(ref);
QDeclarativeDebugPropertyReference copyAssign;
copyAssign = ref;
diff --git a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
index 2a28a45..d41cfa3 100644
--- a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
+++ b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
@@ -88,7 +88,7 @@ void tst_QDeclarativeDebugClient::initTestCase()
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
bool ok = m_conn->waitForConnected();
- Q_ASSERT(ok);
+ QVERIFY(ok);
QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
QTRY_COMPARE(client.status(), QDeclarativeDebugClient::Enabled);
diff --git a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
index 4bbb27d..3fa8bba 100644
--- a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
+++ b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
@@ -87,7 +87,7 @@ void tst_QDeclarativeDebugService::initTestCase()
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
bool ok = m_conn->waitForConnected();
- Q_ASSERT(ok);
+ QVERIFY(ok);
QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 44440a8..71214a3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -2162,16 +2162,12 @@ public:
~CppOwnershipReturnValue() { delete value; }
Q_INVOKABLE QObject *create() {
- Q_ASSERT(value == 0);
-
value = new QObject;
QDeclarativeEngine::setObjectOwnership(value, QDeclarativeEngine::CppOwnership);
return value;
}
Q_INVOKABLE MyQmlObject *createQmlObject() {
- Q_ASSERT(value == 0);
-
MyQmlObject *rv = new MyQmlObject;
value = rv;
return rv;
diff --git a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
index 689c20d..9b2704b 100644
--- a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
+++ b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
@@ -55,13 +55,13 @@
#endif
class tst_qdeclarativefontloader : public QObject
-
{
Q_OBJECT
public:
tst_qdeclarativefontloader();
private slots:
+ void init();
void noFont();
void namedFont();
void localFont();
@@ -71,8 +71,6 @@ private slots:
void failWebFont();
void changeFont();
-private slots:
-
private:
QDeclarativeEngine engine;
TestHTTPServer server;
@@ -82,7 +80,11 @@ tst_qdeclarativefontloader::tst_qdeclarativefontloader() :
server(SERVER_PORT)
{
server.serveDirectory(SRCDIR "/data");
- Q_ASSERT(server.isValid());
+}
+
+void tst_qdeclarativefontloader::init()
+{
+ QVERIFY(server.isValid());
}
void tst_qdeclarativefontloader::noFont()
diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview1.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview1.qml
index caa28d6..a2b0a91 100644
--- a/tests/auto/declarative/qdeclarativegridview/data/gridview1.qml
+++ b/tests/auto/declarative/qdeclarativegridview/data/gridview1.qml
@@ -2,6 +2,7 @@ import QtQuick 1.1
Rectangle {
id: root
+ property int count: grid.count
property bool showHeader: false
property bool showFooter: false
property int added: -1
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 03d5b95..e3f7980 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -222,6 +222,7 @@ void tst_QDeclarativeGridView::items()
QTRY_VERIFY(contentItem != 0);
QTRY_COMPARE(gridview->count(), model.count());
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
for (int i = 0; i < model.count(); ++i) {
@@ -305,6 +306,7 @@ void tst_QDeclarativeGridView::inserted()
QTRY_VERIFY(contentItem != 0);
model.insertItem(1, "Will", "9876");
+ QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count());
QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
@@ -382,6 +384,7 @@ void tst_QDeclarativeGridView::removed()
QTRY_VERIFY(contentItem != 0);
model.removeItem(1);
+ QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count());
QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
index 263caf3..214b7af 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
@@ -115,7 +115,6 @@ int tst_qdeclarativelistmodel::roleFromName(const QDeclarativeListModel *model,
if (model->toString(roles[i]) == roleName)
return roles[i];
}
- Q_ASSERT(false);
return -1;
}
@@ -741,6 +740,7 @@ void tst_qdeclarativelistmodel::get()
"}", QUrl());
QDeclarativeListModel *model = qobject_cast<QDeclarativeListModel*>(component.create());
int role = roleFromName(model, roleName);
+ QVERIFY(role >= 0);
QSignalSpy spy(model, SIGNAL(itemsChanged(int, int, QList<int>)));
QDeclarativeExpression expr(eng.rootContext(), model, expression);
@@ -802,6 +802,7 @@ void tst_qdeclarativelistmodel::get_worker()
model.append(sv);
model.append(sv);
int role = roleFromName(&model, roleName);
+ QVERIFY(role >= 0);
const char *warning = "<Unknown File>: QML ListModel: Cannot add list-type data when modifying or after modification from a worker script";
if (roleValue.type() == QVariant::List || roleValue.type() == QVariant::Map)
@@ -893,6 +894,7 @@ void tst_qdeclarativelistmodel::get_nested()
int outerListIndex = testData[i].first;
QString outerListRoleName = testData[i].second;
int outerListRole = roleFromName(model, outerListRoleName);
+ QVERIFY(outerListRole >= 0);
childModel = qobject_cast<QDeclarativeListModel*>(model->data(outerListIndex, outerListRole).value<QObject*>());
QVERIFY(childModel);
@@ -905,6 +907,7 @@ void tst_qdeclarativelistmodel::get_nested()
QVERIFY(!expr.hasError());
int role = roleFromName(childModel, roleName);
+ QVERIFY(role >= 0);
QCOMPARE(childModel->data(index, role), roleValue);
QCOMPARE(spy.count(), 1);
diff --git a/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml b/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml
index 3cd6f42..75ddabb 100644
--- a/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml
@@ -6,6 +6,7 @@ Rectangle {
height: 320
color: "#ffffff"
+ property int count: list.count
property bool showHeader: false
property bool showFooter: false
property real hr: list.visibleArea.heightRatio
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index 542d512..7e7b3f5 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -389,6 +389,7 @@ void tst_QDeclarativeListView::items()
QTRY_VERIFY(listview->highlightItem() != 0);
QTRY_COMPARE(listview->count(), model.count());
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
// current item should be first item
@@ -517,6 +518,7 @@ void tst_QDeclarativeListView::inserted()
model.insertItem(0, "Foo", "1111"); // zero index, and current item
+ QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count());
QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
name = findItem<QDeclarativeText>(contentItem, "textName", 0);
@@ -583,6 +585,7 @@ void tst_QDeclarativeListView::removed(bool animated)
QTRY_VERIFY(contentItem != 0);
model.removeItem(1);
+ QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count());
QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
@@ -711,6 +714,16 @@ void tst_QDeclarativeListView::removed(bool animated)
QTRY_VERIFY(name = findItem<QDeclarativeText>(contentItem, "textName", model.count()-1));
QCOMPARE(name->text(), QString("New"));
+ // Add some more items so that we don't run out
+ for (int i = 50; i < 100; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ // QTBUG-19198 move to end and remove all visible items one at a time.
+ listview->positionViewAtEnd();
+ for (int i = 0; i < 18; ++i)
+ model.removeItems(model.count() - 1, 1);
+ QTRY_VERIFY(findItems<QDeclarativeItem>(contentItem, "wrapper").count() > 16);
+
delete canvas;
}
diff --git a/tests/auto/declarative/qdeclarativemousearea/data/preventContextMenu.qml b/tests/auto/declarative/qdeclarativemousearea/data/preventContextMenu.qml
new file mode 100644
index 0000000..dcbb5d7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativemousearea/data/preventContextMenu.qml
@@ -0,0 +1,22 @@
+import QtQuick 1.1
+import Test 1.0
+
+Item {
+ width: 200
+ height: 200
+
+ property alias mouseAreaEnabled: mouseArea.enabled
+ property alias eventsReceived: receiver.eventCount
+
+ ContextMenuEventReceiver {
+ id: receiver
+ anchors.fill: parent
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
+ enabled: true
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
index e2adfa8..7548ee0 100644
--- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
+++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp
@@ -47,6 +47,7 @@
#include <QtDeclarative/qdeclarativeview.h>
#include <QtDeclarative/qdeclarativecontext.h>
#include <QtDeclarative/qdeclarativeengine.h>
+#include <QtDeclarative/qdeclarativeproperty.h>
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@@ -70,6 +71,9 @@ private slots:
void preventStealing();
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
+#ifndef QT_NO_CONTEXTMENU
+ void preventContextMenu();
+#endif // QT_NO_CONTEXTMENU
private:
QDeclarativeView *createView();
@@ -637,6 +641,65 @@ void tst_QDeclarativeMouseArea::testQtQuick11Attributes_data()
<< ":1 \"MouseArea.preventStealing\" is not available in QtQuick 1.0.\n";
}
+#ifndef QT_NO_CONTEXTMENU
+class ContextMenuEventReceiver : public QDeclarativeItem
+{
+ Q_OBJECT
+ Q_PROPERTY(int eventCount READ eventCount NOTIFY eventCountChanged);
+public:
+ ContextMenuEventReceiver(QDeclarativeItem *parent = 0) : QDeclarativeItem(parent), m_eventCount(0) { }
+ int eventCount() const { return m_eventCount; }
+signals:
+ void eventCountChanged(int);
+protected:
+ void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
+ if (event->reason() == QGraphicsSceneContextMenuEvent::Mouse) {
+ m_eventCount++;
+ emit eventCountChanged(m_eventCount);
+ }
+ }
+private:
+ int m_eventCount;
+};
+
+void tst_QDeclarativeMouseArea::preventContextMenu()
+{
+ // A MouseArea accepting Left, Middle and Right buttons should prevent context menu
+ // events with "Mouse" reason to hit the Item below.
+
+ qmlRegisterType<ContextMenuEventReceiver>("Test", 1, 0, "ContextMenuEventReceiver");
+
+ QDeclarativeView *view = createView();
+ view->setSource(QUrl::fromLocalFile(SRCDIR "/data/preventContextMenu.qml"));
+ view->show();
+ QVERIFY(view->rootObject() != 0);
+
+ QDeclarativeProperty mouseAreaEnabled(view->rootObject(), "mouseAreaEnabled");
+ QVERIFY(mouseAreaEnabled.read().toBool());
+
+ QDeclarativeProperty eventsReceived(view->rootObject(), "eventsReceived");
+ QCOMPARE(eventsReceived.read().toInt(), 0);
+
+ QPoint targetPoint = view->mapFromScene(QPoint(80, 80));
+
+ QContextMenuEvent fakeEvent1(QContextMenuEvent::Mouse, targetPoint);
+ QApplication::sendEvent(view->viewport(), &fakeEvent1);
+ QCOMPARE(eventsReceived.read().toInt(), 0);
+
+ mouseAreaEnabled.write(false);
+ QVERIFY(!mouseAreaEnabled.read().toBool());
+ QContextMenuEvent fakeEvent2(QContextMenuEvent::Mouse, targetPoint);
+ QApplication::sendEvent(view->viewport(), &fakeEvent2);
+ QCOMPARE(eventsReceived.read().toInt(), 1);
+
+ mouseAreaEnabled.write(true);
+ QVERIFY(mouseAreaEnabled.read().toBool());
+ QContextMenuEvent fakeEvent3(QContextMenuEvent::Mouse, targetPoint);
+ QApplication::sendEvent(view->viewport(), &fakeEvent3);
+ QCOMPARE(eventsReceived.read().toInt(), 1);
+}
+#endif // QT_NO_CONTEXTMENU
+
QTEST_MAIN(tst_QDeclarativeMouseArea)
#include "tst_qdeclarativemousearea.moc"
diff --git a/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml b/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml
index 1322025..e2c4e3d 100644
--- a/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml
@@ -2,6 +2,7 @@ import QtQuick 1.0
PathView {
id: pathview
+ property int viewCount: count
objectName: "pathview"
width: 240; height: 320
pathItemCount: testObject.pathItemCount
diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml
index 04c7717..28b6fb9 100644
--- a/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml
+++ b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml
@@ -2,6 +2,7 @@ import QtQuick 1.0
Rectangle {
id: root
+ property int count: view.count
property int currentA: -1
property int currentB: -1
property real delegateWidth: 60
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index 1f53383..3861ed3 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -253,6 +253,8 @@ void tst_QDeclarativePathView::items()
QDeclarativePathView *pathview = findItem<QDeclarativePathView>(canvas->rootObject(), "view");
QVERIFY(pathview != 0);
+ QCOMPARE(pathview->count(), model.count());
+ QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count());
QCOMPARE(pathview->childItems().count(), model.count()+1); // assumes all are visible, including highlight
for (int i = 0; i < model.count(); ++i) {
@@ -400,6 +402,7 @@ void tst_QDeclarativePathView::dataModel()
model.insertItem(4, "orange", "10");
QTest::qWait(100);
+ QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count());
QTRY_COMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 14);
QVERIFY(pathview->currentIndex() == 0);
@@ -409,6 +412,7 @@ void tst_QDeclarativePathView::dataModel()
QCOMPARE(text->text(), model.name(4));
model.removeItem(2);
+ QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count());
text = findItem<QDeclarativeText>(pathview, "myText", 2);
QVERIFY(text);
QCOMPARE(text->text(), model.name(2));
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml
new file mode 100644
index 0000000..af23f6d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml
@@ -0,0 +1,8 @@
+import QtQuick 1.1
+
+TextEdit {
+ focus: true
+ text: "0123456789ABCDEFGHIJKLMNOPQRS\nTUVWXYZ"
+ selectByMouse: true
+ mouseSelectionMode: TextInput.SelectWords
+}
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index 3f30a52..8530c7f 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -119,6 +119,7 @@ private slots:
void moveCursorSelectionSequence();
void mouseSelection_data();
void mouseSelection();
+ void multilineMouseSelection();
void deferEnableSelectByMouse_data();
void deferEnableSelectByMouse();
void deferDisableSelectByMouse_data();
@@ -1364,6 +1365,41 @@ void tst_qdeclarativetextedit::mouseSelection()
delete canvas;
}
+void tst_qdeclarativetextedit::multilineMouseSelection()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/mouseselection_multiline.qml");
+
+ canvas->show();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QVERIFY(canvas->rootObject() != 0);
+ QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit *>(canvas->rootObject());
+ QVERIFY(textEditObject != 0);
+
+ // press-and-drag from x1,y1 to x2,y1
+ int x1 = 10;
+ int x2 = textEditObject->width() - 10;
+ int y1 = textEditObject->height() / 4;
+ int y2 = textEditObject->height() * 3 / 4;
+ QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y1)));
+ QMouseEvent mv1(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y1)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv1);
+ QString str1 = textEditObject->selectedText();
+ QVERIFY(str1.length() > 3); // don't reallly care *what* was selected (and it's too sensitive to platform)
+
+ // drag-and-release from x2,y1 to x2,y2
+ QMouseEvent mv2(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y2)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv2);
+ QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y2)));
+ QString str2 = textEditObject->selectedText();
+ QVERIFY(str1 != str2);
+ QVERIFY(str2.length() > 3);
+
+ delete canvas;
+}
+
void tst_qdeclarativetextedit::deferEnableSelectByMouse_data()
{
QTest::addColumn<QString>("qmlfile");
@@ -1639,6 +1675,26 @@ void tst_qdeclarativetextedit::cursorDelegate()
QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
}
+ // Clear preedit text;
+ QInputMethodEvent event;
+ QApplication::sendEvent(view, &event);
+
+ // Test delegate gets moved on mouse press.
+ textEditObject->setSelectByMouse(true);
+ textEditObject->setCursorPosition(0);
+ qDebug() << textEditObject->boundingRect() << textEditObject->positionToRectangle(5).center() << view->mapFromScene(textEditObject->positionToRectangle(5).center());
+ QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->mapFromScene(textEditObject->positionToRectangle(5).center()));
+ QVERIFY(textEditObject->cursorPosition() != 0);
+ QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+
+ textEditObject->setReadOnly(true);
+ textEditObject->setCursorPosition(0);
+ QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->mapFromScene(textEditObject->positionToRectangle(5).center()));
+ QVERIFY(textEditObject->cursorPosition() != 0);
+ QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+
textEditObject->setCursorPosition(0);
QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
index 2074468..7df2dc3 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
@@ -126,7 +126,10 @@ private:
QStringList fields = item.split(",");
foreach(const QString &field, fields) {
QStringList values = field.split("=");
- Q_ASSERT(values.count() == 2);
+ if (values.count() != 2) {
+ qWarning() << "makeItemXmlAndData: invalid field:" << field;
+ continue;
+ }
xml += QString("<%1>%2</%1>").arg(values[0], values[1]);
if (!modelData)
continue;
diff --git a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp
index bd95a52..fa3926f 100644
--- a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp
+++ b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp
@@ -185,16 +185,22 @@ QString tst_qmlvisual::toTestScript(const QString &file, Mode mode)
if (platformsuffix && (mode == UpdatePlatformVisuals || QFile::exists(testdata+QLatin1String(platformsuffix)+QDir::separator()+testname+".qml"))) {
QString platformdir = testdata + QLatin1String(platformsuffix);
if (mode == UpdatePlatformVisuals) {
- Q_ASSERT(QDir().mkpath(platformdir));
+ if (!QDir().mkpath(platformdir)) {
+ qFatal("Cannot make path %s", qPrintable(platformdir));
+ }
// Copy from base
QDir dir(testdata,testname+".*");
dir.setFilter(QDir::Files);
QFileInfoList list = dir.entryInfoList();
for (int i = 0; i < list.size(); ++i) {
QFile in(list.at(i).filePath());
- Q_ASSERT(in.open(QIODevice::ReadOnly));
+ if (!in.open(QIODevice::ReadOnly)) {
+ qFatal("Cannot open file %s: %s", qPrintable(in.fileName()), qPrintable(in.errorString()));
+ }
QFile out(platformdir + QDir::separator() + list.at(i).fileName());
- Q_ASSERT(out.open(QIODevice::WriteOnly));
+ if (!out.open(QIODevice::WriteOnly)) {
+ qFatal("Cannot open file %s: %s", qPrintable(out.fileName()), qPrintable(out.errorString()));
+ }
out.write(in.readAll());
}
}
@@ -234,8 +240,6 @@ QStringList tst_qmlvisual::findQmlFiles(const QDir &d)
void action(Mode mode, const QString &file)
{
- Q_ASSERT(mode != Test);
-
QString testdata = tst_qmlvisual::toTestScript(file,mode);
QStringList arguments;
diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp
index cf78977..3cfcc49 100644
--- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp
+++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp
@@ -60,7 +60,7 @@ QT_USE_NAMESPACE
#include "3rdparty/memcheck.h"
#endif
-class tst_ExceptionSafetyObjects: public QObject
+class tst_ExceptionSafety_Objects: public QObject
{
Q_OBJECT
@@ -156,7 +156,7 @@ struct DirCreator : public AbstractTester
}
};
-void tst_ExceptionSafetyObjects::objects_data()
+void tst_ExceptionSafety_Objects::objects_data()
{
QTest::addColumn<AbstractTester *>("objectCreator");
@@ -164,12 +164,12 @@ void tst_ExceptionSafetyObjects::objects_data()
NEWROW(QObject);
NEWROW(QBuffer);
NEWROW(QFile);
+ NEWROW(QFSFileEngine);
NEWROW(QProcess);
NEWROW(QSettings);
NEWROW(QThread);
NEWROW(QThreadPool);
NEWROW(QTranslator);
- NEWROW(QFSFileEngine);
#define NEWROW2(T, CREATOR) QTest::newRow(#T) << static_cast<AbstractTester *>(new CREATOR)
NEWROW2(QBitArray, BitArrayCreator);
@@ -177,7 +177,6 @@ void tst_ExceptionSafetyObjects::objects_data()
NEWROW2(QCryptographicHash, CryptographicHashCreator);
NEWROW2(QDataStream, DataStreamCreator);
NEWROW2(QDir, DirCreator);
-
}
// create and destructs an object, and lets each and every allocation
@@ -274,9 +273,9 @@ public:
}
};
-QtMsgHandler tst_ExceptionSafetyObjects::testMessageHandler;
+QtMsgHandler tst_ExceptionSafety_Objects::testMessageHandler;
-void tst_ExceptionSafetyObjects::safeMessageHandler(QtMsgType type, const char *msg)
+void tst_ExceptionSafety_Objects::safeMessageHandler(QtMsgType type, const char *msg)
{
// this temporarily suspends OOM testing while handling a message
int currentIndex = mallocFailIndex;
@@ -301,7 +300,7 @@ void debugUnexpected()
(*defaultUnexpected)();
}
-void tst_ExceptionSafetyObjects::initTestCase()
+void tst_ExceptionSafety_Objects::initTestCase()
{
// set handlers for bad exception cases, you might want to step in and breakpoint the default handlers too
defaultTerminate = std::set_terminate(&debugTerminate);
@@ -345,17 +344,25 @@ void tst_ExceptionSafetyObjects::initTestCase()
QCOMPARE(malloc2Failed, 1);
}
-void tst_ExceptionSafetyObjects::cleanupTestCase()
+void tst_ExceptionSafety_Objects::cleanupTestCase()
{
qInstallMsgHandler(testMessageHandler);
}
-void tst_ExceptionSafetyObjects::objects()
+void tst_ExceptionSafety_Objects::objects()
{
+ QLatin1String tag = QLatin1String(QTest::currentDataTag());
+ if (tag == QLatin1String("QFile")
+ || tag == QLatin1String("QProcess")
+ || tag == QLatin1String("QSettings")
+ || tag == QLatin1String("QThread")
+ || tag == QLatin1String("QThreadPool"))
+ QSKIP("This type of object is not currently strongly exception safe", SkipSingle);
+
QFETCH(AbstractTester *, objectCreator);
doOOMTest(*objectCreator, 0);
-
+
delete objectCreator;
}
@@ -364,7 +371,8 @@ struct WidgetCreator : public AbstractTester
{
void operator()(QObject *parent)
{
- Q_ASSERT(!parent || parent->isWidgetType());
+ if (parent && !parent->isWidgetType())
+ qFatal("%s: parent must be either null or a widget type", Q_FUNC_INFO);
QScopedPointer<T> ptr(parent ? new T(static_cast<QWidget *>(parent)) : new T);
}
};
@@ -374,7 +382,8 @@ template <> struct WidgetCreator<QSizeGrip> : public AbstractTester
{
void operator()(QObject *parent)
{
- Q_ASSERT(!parent || parent->isWidgetType());
+ if (parent && !parent->isWidgetType())
+ qFatal("%s: parent must be either null or a widget type", Q_FUNC_INFO);
QScopedPointer<QSizeGrip> ptr(new QSizeGrip(static_cast<QWidget *>(parent)));
}
};
@@ -384,17 +393,18 @@ template <> struct WidgetCreator<QDesktopWidget> : public AbstractTester
{
void operator()(QObject *parent)
{
- Q_ASSERT(!parent || parent->isWidgetType());
+ if (parent && !parent->isWidgetType())
+ qFatal("%s: parent must be either null or a widget type", Q_FUNC_INFO);
QScopedPointer<QDesktopWidget> ptr(new QDesktopWidget());
}
};
-void tst_ExceptionSafetyObjects::widgets_data()
+void tst_ExceptionSafety_Objects::widgets_data()
{
#ifdef Q_OS_SYMBIAN
// Initialise the S60 rasteriser, which crashes if started while out of memory
- QImage image(20, 20, QImage::Format_RGB32);
- QPainter p(&image);
- p.drawText(0, 15, "foo");
+ QImage image(20, 20, QImage::Format_RGB32);
+ QPainter p(&image);
+ p.drawText(0, 15, "foo");
#endif
QTest::addColumn<AbstractTester *>("widgetCreator");
@@ -405,23 +415,27 @@ void tst_ExceptionSafetyObjects::widgets_data()
NEWROW(QWidget);
NEWROW(QButtonGroup);
- NEWROW(QDesktopWidget);
NEWROW(QCheckBox);
+ NEWROW(QColumnView);
NEWROW(QComboBox);
NEWROW(QCommandLinkButton);
NEWROW(QDateEdit);
NEWROW(QDateTimeEdit);
+ NEWROW(QDesktopWidget);
NEWROW(QDial);
NEWROW(QDoubleSpinBox);
NEWROW(QFocusFrame);
NEWROW(QFontComboBox);
NEWROW(QFrame);
NEWROW(QGroupBox);
- NEWROW(QLCDNumber);
NEWROW(QLabel);
NEWROW(QLCDNumber);
NEWROW(QLineEdit);
+ NEWROW(QListView);
+ NEWROW(QListWidget);
+ NEWROW(QMainWindow);
NEWROW(QMenu);
+ NEWROW(QMenuBar);
NEWROW(QPlainTextEdit);
NEWROW(QProgressBar);
NEWROW(QPushButton);
@@ -435,28 +449,58 @@ void tst_ExceptionSafetyObjects::widgets_data()
NEWROW(QStackedWidget);
NEWROW(QStatusBar);
NEWROW(QTabBar);
+ NEWROW(QTableView);
+ NEWROW(QTableWidget);
NEWROW(QTabWidget);
NEWROW(QTextBrowser);
NEWROW(QTextEdit);
NEWROW(QTimeEdit);
+ NEWROW(QToolBar);
NEWROW(QToolBox);
NEWROW(QToolButton);
- NEWROW(QStatusBar);
- NEWROW(QToolBar);
- NEWROW(QMenuBar);
- NEWROW(QMainWindow);
- NEWROW(QWorkspace);
- NEWROW(QColumnView);
- NEWROW(QListView);
- NEWROW(QListWidget);
- NEWROW(QTableView);
- NEWROW(QTableWidget);
NEWROW(QTreeView);
NEWROW(QTreeWidget);
+ NEWROW(QWorkspace);
}
-void tst_ExceptionSafetyObjects::widgets()
-{
+void tst_ExceptionSafety_Objects::widgets()
+{
+ QLatin1String tag = QLatin1String(QTest::currentDataTag());
+ if (tag == QLatin1String("QColumnView")
+ || tag == QLatin1String("QComboBox")
+ || tag == QLatin1String("QCommandLinkButton")
+ || tag == QLatin1String("QDateEdit")
+ || tag == QLatin1String("QDateTimeEdit")
+ || tag == QLatin1String("QDesktopWidget")
+ || tag == QLatin1String("QDoubleSpinBox")
+ || tag == QLatin1String("QFontComboBox")
+ || tag == QLatin1String("QGroupBox")
+ || tag == QLatin1String("QLineEdit")
+ || tag == QLatin1String("QListView")
+ || tag == QLatin1String("QListWidget")
+ || tag == QLatin1String("QMainWindow")
+ || tag == QLatin1String("QMenu")
+ || tag == QLatin1String("QMenuBar")
+ || tag == QLatin1String("QPlainTextEdit")
+ || tag == QLatin1String("QProgressBar")
+ || tag == QLatin1String("QPushButton")
+ || tag == QLatin1String("QScrollArea")
+ || tag == QLatin1String("QSpinBox")
+ || tag == QLatin1String("QStackedWidget")
+ || tag == QLatin1String("QStatusBar")
+ || tag == QLatin1String("QTableView")
+ || tag == QLatin1String("QTableWidget")
+ || tag == QLatin1String("QTabWidget")
+ || tag == QLatin1String("QTextBrowser")
+ || tag == QLatin1String("QTextEdit")
+ || tag == QLatin1String("QTimeEdit")
+ || tag == QLatin1String("QToolBar")
+ || tag == QLatin1String("QToolBox")
+ || tag == QLatin1String("QTreeView")
+ || tag == QLatin1String("QTreeWidget")
+ || tag == QLatin1String("QWorkspace"))
+ QSKIP("This type of widget is not currently strongly exception safe", SkipSingle);
+
QFETCH(AbstractTester *, widgetCreator);
doOOMTest(*widgetCreator, 0, 00000);
@@ -547,7 +591,9 @@ struct IntegerMoveable
};
int IntegerMoveable::instanceCount = 0;
+QT_BEGIN_NAMESPACE
Q_DECLARE_TYPEINFO(IntegerMoveable, Q_MOVABLE_TYPE);
+QT_END_NAMESPACE
template <typename T, template<typename> class Container>
void containerInsertTest(QObject*)
@@ -720,12 +766,12 @@ static void containerData()
QTest::newRow("erase moveable") << static_cast<TestFunction>(containerEraseTest<IntegerMoveable, Container>);
}
-void tst_ExceptionSafetyObjects::vector_data()
+void tst_ExceptionSafety_Objects::vector_data()
{
containerData<QVector>();
}
-void tst_ExceptionSafetyObjects::vector()
+void tst_ExceptionSafety_Objects::vector()
{
QFETCH(TestFunction, testFunction);
@@ -736,30 +782,30 @@ void tst_ExceptionSafetyObjects::vector()
doOOMTest(testFunction, 0);
}
-void tst_ExceptionSafetyObjects::list_data()
+void tst_ExceptionSafety_Objects::list_data()
{
containerData<QList>();
}
-void tst_ExceptionSafetyObjects::list()
+void tst_ExceptionSafety_Objects::list()
{
QFETCH(TestFunction, testFunction);
doOOMTest(testFunction, 0);
}
-void tst_ExceptionSafetyObjects::linkedList_data()
+void tst_ExceptionSafety_Objects::linkedList_data()
{
containerData<QLinkedList>();
}
-void tst_ExceptionSafetyObjects::linkedList()
+void tst_ExceptionSafety_Objects::linkedList()
{
QFETCH(TestFunction, testFunction);
doOOMTest(testFunction, 0);
}
-QTEST_MAIN(tst_ExceptionSafetyObjects)
+QTEST_MAIN(tst_ExceptionSafety_Objects)
#include "tst_exceptionsafety_objects.moc"
#endif // QT_NO_EXCEPTIONS
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp
index 4252ea4..e86a9f7 100644
--- a/tests/auto/gestures/tst_gestures.cpp
+++ b/tests/auto/gestures/tst_gestures.cpp
@@ -280,7 +280,7 @@ protected:
eventsPtr->canceled << g->gestureType();
break;
default:
- Q_ASSERT(false);
+ qWarning() << "Unknown GestureState enum value:" << static_cast<int>(g->state());
}
}
} else if (event->type() == CustomEvent::EventType) {
@@ -823,7 +823,7 @@ public:
emit gestureCanceled(e->type(), g);
break;
default:
- Q_ASSERT(false);
+ qWarning() << "Unknown GestureState enum value:" << static_cast<int>(g->state());
}
}
} else if (event->type() == CustomEvent::EventType) {
@@ -1518,17 +1518,20 @@ void tst_Gestures::autoCancelGestures()
{
class MockWidget : public GestureWidget {
public:
- MockWidget(const char *name) : GestureWidget(name) { }
+ MockWidget(const char *name) : GestureWidget(name), badGestureEvents(0) { }
bool event(QEvent *event)
{
if (event->type() == QEvent::Gesture) {
QGestureEvent *ge = static_cast<QGestureEvent*>(event);
- Q_ASSERT(ge->gestures().count() == 1); // can't use QCOMPARE here...
+ if (ge->gestures().count() != 1)
+ ++badGestureEvents; // event should contain exactly one gesture
ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext);
}
return GestureWidget::event(event);
}
+
+ int badGestureEvents;
};
const Qt::GestureType secondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
@@ -1563,22 +1566,26 @@ void tst_Gestures::autoCancelGestures()
event.serial = CustomGesture::SerialFinishedThreshold;
QApplication::sendEvent(child, &event);
QCOMPARE(parent.events.all.count(), 2);
+ QCOMPARE(parent.badGestureEvents, 0);
}
void tst_Gestures::autoCancelGestures2()
{
class MockItem : public GestureItem {
public:
- MockItem(const char *name) : GestureItem(name) { }
+ MockItem(const char *name) : GestureItem(name), badGestureEvents(0) { }
bool event(QEvent *event) {
if (event->type() == QEvent::Gesture) {
QGestureEvent *ge = static_cast<QGestureEvent*>(event);
- Q_ASSERT(ge->gestures().count() == 1); // can't use QCOMPARE here...
+ if (ge->gestures().count() != 1)
+ ++badGestureEvents; // event should contain exactly one gesture
ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext);
}
return GestureItem::event(event);
}
+
+ int badGestureEvents;
};
const Qt::GestureType secondGesture = QGestureRecognizer ::registerRecognizer(new CustomGestureRecognizer);
@@ -1614,6 +1621,7 @@ void tst_Gestures::autoCancelGestures2()
event.serial = CustomGesture::SerialFinishedThreshold;
scene.sendEvent(child, &event);
QCOMPARE(parent->events.all.count(), 2);
+ QCOMPARE(parent->badGestureEvents, 0);
}
void tst_Gestures::graphicsViewParentPropagation()
diff --git a/tests/auto/gui.pro b/tests/auto/gui.pro
index 22c5e51..17f56f2 100644
--- a/tests/auto/gui.pro
+++ b/tests/auto/gui.pro
@@ -58,7 +58,7 @@ SUBDIRS=\
qfontdialog \
qfontmetrics \
qformlayout \
- qglyphs \
+ qglyphrun \
qgraphicsanchorlayout \
qgraphicsanchorlayout1 \
qgraphicseffect \
@@ -142,7 +142,6 @@ SUBDIRS=\
qregion \
qscrollarea \
qscrollbar \
- qscroller \
qsharedpointer_and_qwidget \
qshortcut \
qsidebar \
diff --git a/tests/auto/modeltest/dynamictreemodel.cpp b/tests/auto/modeltest/dynamictreemodel.cpp
index 1afe09e..2f8bb0a 100644
--- a/tests/auto/modeltest/dynamictreemodel.cpp
+++ b/tests/auto/modeltest/dynamictreemodel.cpp
@@ -44,6 +44,7 @@
#include <QtCore/QHash>
#include <QtCore/QList>
#include <QtCore/QTimer>
+#include <QtCore/QDebug>
DynamicTreeModel::DynamicTreeModel(QObject *parent)
@@ -66,9 +67,11 @@ QModelIndex DynamicTreeModel::index(int row, int column, const QModelIndex &pare
const qint64 grandParent = findParentId(parent.internalId());
if (grandParent >= 0) {
QList<QList<qint64> > parentTable = m_childItems.value(grandParent);
- Q_ASSERT(parent.column() < parentTable.size());
+ if (parent.column() >= parentTable.size())
+ qFatal("%s: parent.column() must be less than parentTable.size()", Q_FUNC_INFO);
QList<qint64> parentSiblings = parentTable.at(parent.column());
- Q_ASSERT(parent.row() < parentSiblings.size());
+ if (parent.row() >= parentSiblings.size())
+ qFatal("%s: parent.row() must be less than parentSiblings.size()", Q_FUNC_INFO);
}
if (childIdColumns.size() == 0)
@@ -189,7 +192,8 @@ QModelIndex ModelChangeCommand::findIndex(QList<int> rows)
while (i.hasNext())
{
parent = m_model->index(i.next(), col, parent);
- Q_ASSERT(parent.isValid());
+ if (!parent.isValid())
+ qFatal("%s: parent must be valid", Q_FUNC_INFO);
}
return parent;
}
diff --git a/tests/auto/modeltest/modeltest.cpp b/tests/auto/modeltest/modeltest.cpp
index e1e4094..e30d1f6 100644
--- a/tests/auto/modeltest/modeltest.cpp
+++ b/tests/auto/modeltest/modeltest.cpp
@@ -45,8 +45,6 @@
#include "modeltest.h"
#include <QtTest/QtTest>
-#undef Q_ASSERT
-#define Q_ASSERT QVERIFY
Q_DECLARE_METATYPE ( QModelIndex )
@@ -55,7 +53,8 @@ Q_DECLARE_METATYPE ( QModelIndex )
*/
ModelTest::ModelTest ( QAbstractItemModel *_model, QObject *parent ) : QObject ( parent ), model ( _model ), fetchingMore ( false )
{
- Q_ASSERT ( model );
+ if (!model)
+ qFatal("%s: model must not be null", Q_FUNC_INFO);
connect ( model, SIGNAL ( columnsAboutToBeInserted ( const QModelIndex &, int, int ) ),
this, SLOT ( runAllTests() ) );
@@ -118,15 +117,15 @@ void ModelTest::runAllTests()
*/
void ModelTest::nonDestructiveBasicTest()
{
- Q_ASSERT ( model->buddy ( QModelIndex() ) == QModelIndex() );
+ QVERIFY( model->buddy ( QModelIndex() ) == QModelIndex() );
model->canFetchMore ( QModelIndex() );
- Q_ASSERT ( model->columnCount ( QModelIndex() ) >= 0 );
- Q_ASSERT ( model->data ( QModelIndex() ) == QVariant() );
+ QVERIFY( model->columnCount ( QModelIndex() ) >= 0 );
+ QVERIFY( model->data ( QModelIndex() ) == QVariant() );
fetchingMore = true;
model->fetchMore ( QModelIndex() );
fetchingMore = false;
Qt::ItemFlags flags = model->flags ( QModelIndex() );
- Q_ASSERT ( flags == Qt::ItemIsDropEnabled || flags == 0 );
+ QVERIFY( flags == Qt::ItemIsDropEnabled || flags == 0 );
model->hasChildren ( QModelIndex() );
model->hasIndex ( 0, 0 );
model->headerData ( 0, Qt::Horizontal );
@@ -135,8 +134,8 @@ void ModelTest::nonDestructiveBasicTest()
QVariant cache;
model->match ( QModelIndex(), -1, cache );
model->mimeTypes();
- Q_ASSERT ( model->parent ( QModelIndex() ) == QModelIndex() );
- Q_ASSERT ( model->rowCount() >= 0 );
+ QVERIFY( model->parent ( QModelIndex() ) == QModelIndex() );
+ QVERIFY( model->rowCount() >= 0 );
QVariant variant;
model->setData ( QModelIndex(), variant, -1 );
model->setHeaderData ( -1, Qt::Horizontal, QVariant() );
@@ -158,17 +157,17 @@ void ModelTest::rowCount()
// check top row
QModelIndex topIndex = model->index ( 0, 0, QModelIndex() );
int rows = model->rowCount ( topIndex );
- Q_ASSERT ( rows >= 0 );
+ QVERIFY( rows >= 0 );
if ( rows > 0 )
- Q_ASSERT ( model->hasChildren ( topIndex ) == true );
+ QVERIFY( model->hasChildren ( topIndex ) );
QModelIndex secondLevelIndex = model->index ( 0, 0, topIndex );
if ( secondLevelIndex.isValid() ) { // not the top level
// check a row count where parent is valid
rows = model->rowCount ( secondLevelIndex );
- Q_ASSERT ( rows >= 0 );
+ QVERIFY( rows >= 0 );
if ( rows > 0 )
- Q_ASSERT ( model->hasChildren ( secondLevelIndex ) == true );
+ QVERIFY( model->hasChildren ( secondLevelIndex ) );
}
// The models rowCount() is tested more extensively in checkChildren(),
@@ -182,12 +181,12 @@ void ModelTest::columnCount()
{
// check top row
QModelIndex topIndex = model->index ( 0, 0, QModelIndex() );
- Q_ASSERT ( model->columnCount ( topIndex ) >= 0 );
+ QVERIFY( model->columnCount ( topIndex ) >= 0 );
// check a column count where parent is valid
QModelIndex childIndex = model->index ( 0, 0, topIndex );
if ( childIndex.isValid() )
- Q_ASSERT ( model->columnCount ( childIndex ) >= 0 );
+ QVERIFY( model->columnCount ( childIndex ) >= 0 );
// columnCount() is tested more extensively in checkChildren(),
// but this catches the big mistakes
@@ -200,19 +199,19 @@ void ModelTest::hasIndex()
{
// qDebug() << "hi";
// Make sure that invalid values returns an invalid index
- Q_ASSERT ( model->hasIndex ( -2, -2 ) == false );
- Q_ASSERT ( model->hasIndex ( -2, 0 ) == false );
- Q_ASSERT ( model->hasIndex ( 0, -2 ) == false );
+ QVERIFY( !model->hasIndex ( -2, -2 ) );
+ QVERIFY( !model->hasIndex ( -2, 0 ) );
+ QVERIFY( !model->hasIndex ( 0, -2 ) );
int rows = model->rowCount();
int columns = model->columnCount();
// check out of bounds
- Q_ASSERT ( model->hasIndex ( rows, columns ) == false );
- Q_ASSERT ( model->hasIndex ( rows + 1, columns + 1 ) == false );
+ QVERIFY( !model->hasIndex ( rows, columns ) );
+ QVERIFY( !model->hasIndex ( rows + 1, columns + 1 ) );
if ( rows > 0 )
- Q_ASSERT ( model->hasIndex ( 0, 0 ) == true );
+ QVERIFY( model->hasIndex ( 0, 0 ) );
// hasIndex() is tested more extensively in checkChildren(),
// but this catches the big mistakes
@@ -225,9 +224,9 @@ void ModelTest::index()
{
// qDebug() << "i";
// Make sure that invalid values returns an invalid index
- Q_ASSERT ( model->index ( -2, -2 ) == QModelIndex() );
- Q_ASSERT ( model->index ( -2, 0 ) == QModelIndex() );
- Q_ASSERT ( model->index ( 0, -2 ) == QModelIndex() );
+ QVERIFY( model->index ( -2, -2 ) == QModelIndex() );
+ QVERIFY( model->index ( -2, 0 ) == QModelIndex() );
+ QVERIFY( model->index ( 0, -2 ) == QModelIndex() );
int rows = model->rowCount();
int columns = model->columnCount();
@@ -236,13 +235,13 @@ void ModelTest::index()
return;
// Catch off by one errors
- Q_ASSERT ( model->index ( rows, columns ) == QModelIndex() );
- Q_ASSERT ( model->index ( 0, 0 ).isValid() == true );
+ QVERIFY( model->index ( rows, columns ) == QModelIndex() );
+ QVERIFY( model->index ( 0, 0 ).isValid() );
// Make sure that the same index is *always* returned
QModelIndex a = model->index ( 0, 0 );
QModelIndex b = model->index ( 0, 0 );
- Q_ASSERT ( a == b );
+ QVERIFY( a == b );
// index() is tested more extensively in checkChildren(),
// but this catches the big mistakes
@@ -256,7 +255,7 @@ void ModelTest::parent()
// qDebug() << "p";
// Make sure the model wont crash and will return an invalid QModelIndex
// when asked for the parent of an invalid index.
- Q_ASSERT ( model->parent ( QModelIndex() ) == QModelIndex() );
+ QVERIFY( model->parent ( QModelIndex() ) == QModelIndex() );
if ( model->rowCount() == 0 )
return;
@@ -269,13 +268,13 @@ void ModelTest::parent()
// Common error test #1, make sure that a top level index has a parent
// that is a invalid QModelIndex.
QModelIndex topIndex = model->index ( 0, 0, QModelIndex() );
- Q_ASSERT ( model->parent ( topIndex ) == QModelIndex() );
+ QVERIFY( model->parent ( topIndex ) == QModelIndex() );
// Common error test #2, make sure that a second level index has a parent
// that is the first level index.
if ( model->rowCount ( topIndex ) > 0 ) {
QModelIndex childIndex = model->index ( 0, 0, topIndex );
- Q_ASSERT ( model->parent ( childIndex ) == topIndex );
+ QVERIFY( model->parent ( childIndex ) == topIndex );
}
// Common error test #3, the second column should NOT have the same children
@@ -285,7 +284,7 @@ void ModelTest::parent()
if ( model->rowCount ( topIndex1 ) > 0 ) {
QModelIndex childIndex = model->index ( 0, 0, topIndex );
QModelIndex childIndex1 = model->index ( 0, 0, topIndex1 );
- Q_ASSERT ( childIndex != childIndex1 );
+ QVERIFY( childIndex != childIndex1 );
}
// Full test, walk n levels deep through the model making sure that all
@@ -325,47 +324,47 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth )
int columns = model->columnCount ( parent );
if ( rows > 0 )
- Q_ASSERT ( model->hasChildren ( parent ) );
+ QVERIFY( model->hasChildren ( parent ) );
// Some further testing against rows(), columns(), and hasChildren()
- Q_ASSERT ( rows >= 0 );
- Q_ASSERT ( columns >= 0 );
+ QVERIFY( rows >= 0 );
+ QVERIFY( columns >= 0 );
if ( rows > 0 )
- Q_ASSERT ( model->hasChildren ( parent ) == true );
+ QVERIFY( model->hasChildren ( parent ) );
//qDebug() << "parent:" << model->data(parent).toString() << "rows:" << rows
// << "columns:" << columns << "parent column:" << parent.column();
- Q_ASSERT ( model->hasIndex ( rows + 1, 0, parent ) == false );
+ QVERIFY( !model->hasIndex ( rows + 1, 0, parent ) );
for ( int r = 0; r < rows; ++r ) {
if ( model->canFetchMore ( parent ) ) {
fetchingMore = true;
model->fetchMore ( parent );
fetchingMore = false;
}
- Q_ASSERT ( model->hasIndex ( r, columns + 1, parent ) == false );
+ QVERIFY( !model->hasIndex ( r, columns + 1, parent ) );
for ( int c = 0; c < columns; ++c ) {
- Q_ASSERT ( model->hasIndex ( r, c, parent ) == true );
+ QVERIFY( model->hasIndex ( r, c, parent ) );
QModelIndex index = model->index ( r, c, parent );
// rowCount() and columnCount() said that it existed...
- Q_ASSERT ( index.isValid() == true );
+ QVERIFY( index.isValid() );
// index() should always return the same index when called twice in a row
QModelIndex modifiedIndex = model->index ( r, c, parent );
- Q_ASSERT ( index == modifiedIndex );
+ QVERIFY( index == modifiedIndex );
// Make sure we get the same index if we request it twice in a row
QModelIndex a = model->index ( r, c, parent );
QModelIndex b = model->index ( r, c, parent );
- Q_ASSERT ( a == b );
+ QVERIFY( a == b );
// Some basic checking on the index that is returned
- Q_ASSERT ( index.model() == model );
- Q_ASSERT ( index.row() == r );
- Q_ASSERT ( index.column() == c );
+ QVERIFY( index.model() == model );
+ QCOMPARE( index.row(), r );
+ QCOMPARE( index.column(), c );
// While you can technically return a QVariant usually this is a sign
- // of an bug in data() Disable if this really is ok in your model.
-// Q_ASSERT ( model->data ( index, Qt::DisplayRole ).isValid() == true );
+ // of a bug in data(). Disable if this really is ok in your model.
+// QVERIFY( model->data ( index, Qt::DisplayRole ).isValid() );
// If the next test fails here is some somewhat useful debug you play with.
@@ -380,8 +379,7 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth )
}
// Check that we can get back our real parent.
-// qDebug() << model->parent ( index ) << parent ;
- Q_ASSERT ( model->parent ( index ) == parent );
+ QCOMPARE( model->parent ( index ), parent );
// recursively go down the children
if ( model->hasChildren ( index ) && currentDepth < 10 ) {
@@ -391,7 +389,7 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth )
// make sure that after testing the children that the index doesn't change.
QModelIndex newerIndex = model->index ( r, c, parent );
- Q_ASSERT ( index == newerIndex );
+ QVERIFY( index == newerIndex );
}
}
}
@@ -402,68 +400,68 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth )
void ModelTest::data()
{
// Invalid index should return an invalid qvariant
- Q_ASSERT ( !model->data ( QModelIndex() ).isValid() );
+ QVERIFY( !model->data ( QModelIndex() ).isValid() );
if ( model->rowCount() == 0 )
return;
// A valid index should have a valid QVariant data
- Q_ASSERT ( model->index ( 0, 0 ).isValid() );
+ QVERIFY( model->index ( 0, 0 ).isValid() );
// shouldn't be able to set data on an invalid index
- Q_ASSERT ( model->setData ( QModelIndex(), QLatin1String ( "foo" ), Qt::DisplayRole ) == false );
+ QVERIFY( !model->setData ( QModelIndex(), QLatin1String ( "foo" ), Qt::DisplayRole ) );
// General Purpose roles that should return a QString
QVariant variant = model->data ( model->index ( 0, 0 ), Qt::ToolTipRole );
if ( variant.isValid() ) {
- Q_ASSERT ( qVariantCanConvert<QString> ( variant ) );
+ QVERIFY( qVariantCanConvert<QString> ( variant ) );
}
variant = model->data ( model->index ( 0, 0 ), Qt::StatusTipRole );
if ( variant.isValid() ) {
- Q_ASSERT ( qVariantCanConvert<QString> ( variant ) );
+ QVERIFY( qVariantCanConvert<QString> ( variant ) );
}
variant = model->data ( model->index ( 0, 0 ), Qt::WhatsThisRole );
if ( variant.isValid() ) {
- Q_ASSERT ( qVariantCanConvert<QString> ( variant ) );
+ QVERIFY( qVariantCanConvert<QString> ( variant ) );
}
// General Purpose roles that should return a QSize
variant = model->data ( model->index ( 0, 0 ), Qt::SizeHintRole );
if ( variant.isValid() ) {
- Q_ASSERT ( qVariantCanConvert<QSize> ( variant ) );
+ QVERIFY( qVariantCanConvert<QSize> ( variant ) );
}
// General Purpose roles that should return a QFont
QVariant fontVariant = model->data ( model->index ( 0, 0 ), Qt::FontRole );
if ( fontVariant.isValid() ) {
- Q_ASSERT ( qVariantCanConvert<QFont> ( fontVariant ) );
+ QVERIFY( qVariantCanConvert<QFont> ( fontVariant ) );
}
// Check that the alignment is one we know about
QVariant textAlignmentVariant = model->data ( model->index ( 0, 0 ), Qt::TextAlignmentRole );
if ( textAlignmentVariant.isValid() ) {
int alignment = textAlignmentVariant.toInt();
- Q_ASSERT ( alignment == ( alignment & ( Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask ) ) );
+ QCOMPARE( alignment, ( alignment & ( Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask ) ) );
}
// General Purpose roles that should return a QColor
QVariant colorVariant = model->data ( model->index ( 0, 0 ), Qt::BackgroundColorRole );
if ( colorVariant.isValid() ) {
- Q_ASSERT ( qVariantCanConvert<QColor> ( colorVariant ) );
+ QVERIFY( qVariantCanConvert<QColor> ( colorVariant ) );
}
colorVariant = model->data ( model->index ( 0, 0 ), Qt::TextColorRole );
if ( colorVariant.isValid() ) {
- Q_ASSERT ( qVariantCanConvert<QColor> ( colorVariant ) );
+ QVERIFY( qVariantCanConvert<QColor> ( colorVariant ) );
}
// Check that the "check state" is one we know about.
QVariant checkStateVariant = model->data ( model->index ( 0, 0 ), Qt::CheckStateRole );
if ( checkStateVariant.isValid() ) {
int state = checkStateVariant.toInt();
- Q_ASSERT ( state == Qt::Unchecked ||
- state == Qt::PartiallyChecked ||
- state == Qt::Checked );
+ QVERIFY( state == Qt::Unchecked ||
+ state == Qt::PartiallyChecked ||
+ state == Qt::Checked );
}
}
@@ -494,7 +492,7 @@ void ModelTest::rowsAboutToBeInserted ( const QModelIndex &parent, int start, in
void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end )
{
Changing c = insert.pop();
- Q_ASSERT ( c.parent == parent );
+ QVERIFY( c.parent == parent );
// qDebug() << "rowsInserted" << "start=" << start << "end=" << end << "oldsize=" << c.oldSize
// << "parent=" << model->data ( parent ).toString() << "current rowcount of parent=" << model->rowCount ( parent );
@@ -504,8 +502,8 @@ void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end )
// }
// qDebug();
- Q_ASSERT ( c.oldSize + ( end - start + 1 ) == model->rowCount ( parent ) );
- Q_ASSERT ( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) );
+ QVERIFY( c.oldSize + ( end - start + 1 ) == model->rowCount ( parent ) );
+ QVERIFY( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) );
if (c.next != model->data(model->index(end + 1, 0, c.parent))) {
qDebug() << start << end;
@@ -514,7 +512,7 @@ void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end )
qDebug() << c.next << model->data(model->index(end + 1, 0, c.parent));
}
- Q_ASSERT ( c.next == model->data ( model->index ( end + 1, 0, c.parent ) ) );
+ QVERIFY( c.next == model->data ( model->index ( end + 1, 0, c.parent ) ) );
}
void ModelTest::layoutAboutToBeChanged()
@@ -527,7 +525,7 @@ void ModelTest::layoutChanged()
{
for ( int i = 0; i < changing.count(); ++i ) {
QPersistentModelIndex p = changing[i];
- Q_ASSERT ( p == model->index ( p.row(), p.column(), p.parent() ) );
+ QVERIFY( p == model->index ( p.row(), p.column(), p.parent() ) );
}
changing.clear();
}
@@ -557,10 +555,10 @@ void ModelTest::rowsRemoved ( const QModelIndex & parent, int start, int end )
{
qDebug() << "rr" << parent << start << end;
Changing c = remove.pop();
- Q_ASSERT ( c.parent == parent );
- Q_ASSERT ( c.oldSize - ( end - start + 1 ) == model->rowCount ( parent ) );
- Q_ASSERT ( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) );
- Q_ASSERT ( c.next == model->data ( model->index ( start, 0, c.parent ) ) );
+ QVERIFY( c.parent == parent );
+ QVERIFY( c.oldSize - ( end - start + 1 ) == model->rowCount ( parent ) );
+ QVERIFY( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) );
+ QVERIFY( c.next == model->data ( model->index ( start, 0, c.parent ) ) );
}
diff --git a/tests/auto/modeltest/tst_modeltest.cpp b/tests/auto/modeltest/tst_modeltest.cpp
index cfaf210..aba0894 100644
--- a/tests/auto/modeltest/tst_modeltest.cpp
+++ b/tests/auto/modeltest/tst_modeltest.cpp
@@ -201,8 +201,10 @@ class ObservingObject : public QObject
Q_OBJECT
public:
ObservingObject(AccessibleProxyModel *proxy, QObject *parent = 0)
- : QObject(parent),
- m_proxy(proxy)
+ : QObject(parent)
+ , m_proxy(proxy)
+ , storePersistentFailureCount(0)
+ , checkPersistentFailureCount(0)
{
connect(m_proxy, SIGNAL(layoutAboutToBeChanged()), SLOT(storePersistent()));
connect(m_proxy, SIGNAL(layoutChanged()), SLOT(checkPersistent()));
@@ -215,8 +217,14 @@ public slots:
for (int row = 0; row < m_proxy->rowCount(parent); ++row) {
QModelIndex proxyIndex = m_proxy->index(row, 0, parent);
QModelIndex sourceIndex = m_proxy->mapToSource(proxyIndex);
- Q_ASSERT(proxyIndex.isValid());
- Q_ASSERT(sourceIndex.isValid());
+ if (!proxyIndex.isValid()) {
+ qWarning("%s: Invalid proxy index", Q_FUNC_INFO);
+ ++storePersistentFailureCount;
+ }
+ if (!sourceIndex.isValid()) {
+ qWarning("%s: invalid source index", Q_FUNC_INFO);
+ ++storePersistentFailureCount;
+ }
m_persistentSourceIndexes.append(sourceIndex);
m_persistentProxyIndexes.append(proxyIndex);
if (m_proxy->hasChildren(proxyIndex))
@@ -226,12 +234,24 @@ public slots:
void storePersistent()
{
- foreach(const QModelIndex &idx, m_persistentProxyIndexes)
- Q_ASSERT(idx.isValid()); // This is called from layoutAboutToBeChanged. Persistent indexes should be valid
-
- Q_ASSERT(m_proxy->persistent().isEmpty());
+ // This method is called from layoutAboutToBeChanged. Persistent indexes should be valid
+ foreach(const QModelIndex &idx, m_persistentProxyIndexes)
+ if (!idx.isValid()) {
+ qWarning("%s: persistentProxyIndexes contains invalid index", Q_FUNC_INFO);
+ ++storePersistentFailureCount;
+ }
+
+ if (!m_proxy->persistent().isEmpty()) {
+ qWarning("%s: proxy should have no persistent indexes when storePersistent called",
+ Q_FUNC_INFO);
+ ++storePersistentFailureCount;
+ }
storePersistent(QModelIndex());
- Q_ASSERT(!m_proxy->persistent().isEmpty());
+ if (m_proxy->persistent().isEmpty()) {
+ qWarning("%s: proxy should have persistent index after storePersistent called",
+ Q_FUNC_INFO);
+ ++storePersistentFailureCount;
+ }
}
void checkPersistent()
@@ -243,7 +263,10 @@ public slots:
for (int row = 0; row < m_persistentProxyIndexes.size(); ++row) {
QModelIndex updatedProxy = m_persistentProxyIndexes.at(row);
QModelIndex updatedSource = m_persistentSourceIndexes.at(row);
- QCOMPARE(m_proxy->mapToSource(updatedProxy), updatedSource);
+ if (m_proxy->mapToSource(updatedProxy) != updatedSource) {
+ qWarning("%s: check failed at row %d", Q_FUNC_INFO, row);
+ ++checkPersistentFailureCount;
+ }
}
m_persistentSourceIndexes.clear();
m_persistentProxyIndexes.clear();
@@ -253,6 +276,9 @@ private:
AccessibleProxyModel *m_proxy;
QList<QPersistentModelIndex> m_persistentSourceIndexes;
QList<QPersistentModelIndex> m_persistentProxyIndexes;
+public:
+ int storePersistentFailureCount;
+ int checkPersistentFailureCount;
};
void tst_ModelTest::moveSourceItems()
@@ -280,6 +306,9 @@ void tst_ModelTest::moveSourceItems()
moveCommand->setDestAncestors(QList<int>() << 1);
moveCommand->setDestRow(0);
moveCommand->doCommand();
+
+ QCOMPARE(observer.storePersistentFailureCount, 0);
+ QCOMPARE(observer.checkPersistentFailureCount, 0);
}
void tst_ModelTest::testResetThroughProxy()
@@ -302,6 +331,9 @@ void tst_ModelTest::testResetThroughProxy()
ModelResetCommand *resetCommand = new ModelResetCommand(model, this);
resetCommand->setNumCols(0);
resetCommand->doCommand();
+
+ QCOMPARE(observer.storePersistentFailureCount, 0);
+ QCOMPARE(observer.checkPersistentFailureCount, 0);
}
diff --git a/tests/auto/other.pro b/tests/auto/other.pro
index 8819879..655d666 100644
--- a/tests/auto/other.pro
+++ b/tests/auto/other.pro
@@ -3,10 +3,8 @@
TEMPLATE=subdirs
SUBDIRS=\
-# exceptionsafety_objects \ shouldn't enable it
# baselineexample \ Just an example demonstrating qbaselinetest usage
lancelot \
- qaccessibility \
qalgorithms \
qcombobox \
qcssparser \
@@ -37,6 +35,8 @@ SUBDIRS=\
windowsmobile \
nativeimagehandleprovider
+contains(QT_CONFIG, accessibility):SUBDIRS += qaccessibility
+
contains(QT_CONFIG, OdfWriter):SUBDIRS += qzip qtextodfwriter
mac: {
SUBDIRS += macgui \
@@ -56,6 +56,8 @@ symbian {
qs60mainapplication
}
+!win32-msvc*:!wince*:SUBDIRS += exceptionsafety_objects
+
# Following tests depends on private API
!contains(QT_CONFIG, private_tests): SUBDIRS -= \
qcssparser \
diff --git a/tests/auto/q3listview/tst_q3listview.cpp b/tests/auto/q3listview/tst_q3listview.cpp
index f0d7937..091e02d 100644
--- a/tests/auto/q3listview/tst_q3listview.cpp
+++ b/tests/auto/q3listview/tst_q3listview.cpp
@@ -678,7 +678,7 @@ void tst_Q3ListView::selections_mouseClick()
for (i = 0; i < items.count(); ++i) {
Q3ListViewItem *item = items.at(i);
- Q_ASSERT(item);
+ QVERIFY(item);
if ( item->isSelected() ) {
QVERIFY( selectedItems.contains( i ) );
} else {
diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
index 58b014b..66bd6bb 100644
--- a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
+++ b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
@@ -251,7 +251,7 @@ void tst_Q3SqlCursor::copyConstructor()
}
QSqlRecord* rec = cur2.primeUpdate();
- Q_ASSERT( rec );
+ QVERIFY( rec );
QCOMPARE( (int)rec->count(), 4 );
int i = 0;
@@ -398,7 +398,7 @@ void tst_Q3SqlCursor::batchInsert()
int i = 0;
for ( ; i < 100; ++i ) {
QSqlRecord* irec = cur.primeInsert();
- Q_ASSERT( irec );
+ QVERIFY( irec );
irec->setValue( "id", i );
irec->setValue( "t_varchar", "blah" );
irec->setValue( "t_char", "blah" );
@@ -412,7 +412,7 @@ void tst_Q3SqlCursor::batchInsert()
for ( ; i < 200; ++i ) {
QSqlRecord* irec = cur.primeInsert();
- Q_ASSERT( irec );
+ QVERIFY( irec );
irec->setValue( "id", i );
irec->setValue( "t_varchar", "blah" );
irec->setValue( "t_char", "blah" );
@@ -699,7 +699,7 @@ void tst_Q3SqlCursor::updateNoPK()
Q3SqlCursor cur(qTableName("qtestPK", __FILE__), true, db);
QSqlRecord* rec = cur.primeInsert();
- Q_ASSERT(rec);
+ QVERIFY(rec);
rec->setNull(0);
rec->setNull(1);
rec->setNull(2);
@@ -724,7 +724,7 @@ void tst_Q3SqlCursor::updateNoPK()
}
rec = cur.primeUpdate();
- Q_ASSERT(rec);
+ QVERIFY(rec);
rec->setValue(0, 1);
rec->setNull(1);
rec->setNull(2);
diff --git a/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp b/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp
index f03b33f..a816333 100644
--- a/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp
+++ b/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp
@@ -83,8 +83,12 @@ public:
bool open(QIODevice::OpenMode openMode)
{
- Q_ASSERT(!openForRead_);
- Q_ASSERT(!openForWrite_);
+ if (openForRead_ || openForWrite_) {
+ qWarning("%s: file is already open for %s",
+ Q_FUNC_INFO,
+ (openForRead_ ? "reading" : "writing"));
+ return false;
+ }
openFile_ = resolveFile(openMode & QIODevice::WriteOnly);
if (!openFile_)
@@ -132,13 +136,19 @@ public:
qint64 pos() const
{
- Q_ASSERT(openForRead_ || openForWrite_);
+ if (!openForRead_ && !openForWrite_) {
+ qWarning("%s: file is not open", Q_FUNC_INFO);
+ return -1;
+ }
return position_;
}
bool seek(qint64 pos)
{
- Q_ASSERT(openForRead_ || openForWrite_);
+ if (!openForRead_ && !openForWrite_) {
+ qWarning("%s: file is not open", Q_FUNC_INFO);
+ return false;
+ }
if (pos >= 0) {
position_ = pos;
@@ -150,7 +160,11 @@ public:
bool flush()
{
- Q_ASSERT(openForRead_ || openForWrite_);
+ if (!openForRead_ && !openForWrite_) {
+ qWarning("%s: file is not open", Q_FUNC_INFO);
+ return false;
+ }
+
return true;
}
@@ -346,10 +360,10 @@ public:
void setFileName(const QString &file)
{
- Q_ASSERT(!openForRead_);
- Q_ASSERT(!openForWrite_);
-
- fileName_ = file;
+ if (openForRead_ || openForWrite_)
+ qWarning("%s: Can't set file name while file is open", Q_FUNC_INFO);
+ else
+ fileName_ = file;
}
// typedef QAbstractFileEngineIterator Iterator;
@@ -368,9 +382,16 @@ public:
qint64 read(char *data, qint64 maxLen)
{
- Q_ASSERT(openForRead_);
+ if (!openForRead_) {
+ qWarning("%s: file must be open for reading", Q_FUNC_INFO);
+ return -1;
+ }
+
+ if (openFile_.isNull()) {
+ qWarning("%s: file must not be null", Q_FUNC_INFO);
+ return -1;
+ }
- Q_ASSERT(!openFile_.isNull());
QMutexLocker lock(&openFile_->mutex);
qint64 readSize = qMin(openFile_->content.size() - position_, maxLen);
if (readSize < 0)
@@ -384,12 +405,19 @@ public:
qint64 write(const char *data, qint64 length)
{
- Q_ASSERT(openForWrite_);
+ if (!openForWrite_) {
+ qWarning("%s: file must be open for writing", Q_FUNC_INFO);
+ return -1;
+ }
+
+ if (openFile_.isNull()) {
+ qWarning("%s: file must not be null", Q_FUNC_INFO);
+ return -1;
+ }
if (length < 0)
return -1;
- Q_ASSERT(!openFile_.isNull());
QMutexLocker lock(&openFile_->mutex);
if (openFile_->content.size() == position_)
openFile_->content.append(data, length);
@@ -434,7 +462,8 @@ protected:
QSharedPointer<File> resolveFile(bool create) const
{
if (openForRead_ || openForWrite_) {
- Q_ASSERT(openFile_);
+ if (!openFile_)
+ qWarning("%s: file should not be null", Q_FUNC_INFO);
return openFile_;
}
diff --git a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp
index 2d17e29..794eb4f 100644
--- a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp
+++ b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp
@@ -39,7 +39,6 @@
**
****************************************************************************/
-
#include <QFile>
#include <QStack>
@@ -54,7 +53,6 @@ LoadingModel::LoadingModel(const Node::Vector &content,
const QXmlNamePool &np) : QSimpleXmlNodeModel(np)
, m_nodes(content)
{
- Q_ASSERT(!content.isEmpty());
/*
foreach(const Node *n, content)
qDebug() << "this:" << n
@@ -79,20 +77,21 @@ const LoadingModel::Node *LoadingModel::toInternal(const QXmlNodeModelIndex &ni)
QXmlNodeModelIndex LoadingModel::createIndex(const Node *const internal) const
{
- Q_ASSERT_X(internal, Q_FUNC_INFO,
- "We shouldn't construct from null pointers.");
+ if (!internal)
+ qFatal("%s: cannot construct a model index from a null pointer", Q_FUNC_INFO);
return QAbstractXmlNodeModel::createIndex(const_cast<Node *>(internal));
}
QUrl LoadingModel::documentUri(const QXmlNodeModelIndex &) const
{
- Q_ASSERT(false);
+ qFatal("%s: This method should not be called during the test", Q_FUNC_INFO);
return QUrl();
}
QXmlNodeModelIndex::NodeKind LoadingModel::kind(const QXmlNodeModelIndex &ni) const
{
- Q_ASSERT(!ni.isNull());
+ if (ni.isNull())
+ qFatal("%s: node model index should not be null", Q_FUNC_INFO);
return toInternal(ni)->kind;
}
@@ -100,8 +99,10 @@ QXmlNodeModelIndex::DocumentOrder LoadingModel::compareOrder(const QXmlNodeModel
{
const Node *const in1 = toInternal(n1);
const Node *const in2 = toInternal(n2);
- Q_ASSERT(m_nodes.indexOf(in1) != -1);
- Q_ASSERT(m_nodes.indexOf(in2) != -1);
+ if (m_nodes.indexOf(in1) == -1)
+ qFatal("%s: node n1 is not in internal node list", Q_FUNC_INFO);
+ if (m_nodes.indexOf(in2) == -1)
+ qFatal("%s: node n2 is not in internal node list", Q_FUNC_INFO);
if(in1 == in2)
return QXmlNodeModelIndex::Is;
@@ -113,7 +114,10 @@ QXmlNodeModelIndex::DocumentOrder LoadingModel::compareOrder(const QXmlNodeModel
QXmlNodeModelIndex LoadingModel::root(const QXmlNodeModelIndex &) const
{
- Q_ASSERT(kind(createIndex(m_nodes.first())) == QXmlNodeModelIndex::Document);
+ if (kind(createIndex(m_nodes.first())) != QXmlNodeModelIndex::Document) {
+ qWarning("%s: first node must be a Document node", Q_FUNC_INFO);
+ return QXmlNodeModelIndex();
+ }
return createIndex(m_nodes.first());
}
@@ -126,8 +130,11 @@ QVariant LoadingModel::typedValue(const QXmlNodeModelIndex &ni) const
{
const Node *const internal = toInternal(ni);
- Q_ASSERT(internal->kind == QXmlNodeModelIndex::Attribute
- || internal->kind == QXmlNodeModelIndex::Element);
+ if (internal->kind != QXmlNodeModelIndex::Attribute
+ && internal->kind != QXmlNodeModelIndex::Element) {
+ qWarning("%s: node must be an attribute or element", Q_FUNC_INFO);
+ return QVariant();
+ }
return internal->value;
}
@@ -167,10 +174,10 @@ QXmlNodeModelIndex LoadingModel::nextFromSimpleAxis(QAbstractXmlNodeModel::Simpl
return internal->precedingSibling ? createIndex(internal->precedingSibling) : QXmlNodeModelIndex();
case NextSibling:
return internal->followingSibling ? createIndex(internal->followingSibling) : QXmlNodeModelIndex();
+ default:
+ qWarning("%s: unknown axis enum value %d", Q_FUNC_INFO, static_cast<int>(axis));
+ return QXmlNodeModelIndex();
}
-
- Q_ASSERT(false);
- return QXmlNodeModelIndex();
}
QVector<QXmlNodeModelIndex> LoadingModel::attributes(const QXmlNodeModelIndex &ni) const
@@ -326,18 +333,16 @@ void Loader::load()
break;
}
case QXmlStreamReader::DTD:
- /* Fallthrough. */
+ qFatal("%s: QXmlStreamReader::DTD token is not supported", Q_FUNC_INFO);
+ break;
case QXmlStreamReader::EntityReference:
- {
- Q_ASSERT_X(false, Q_FUNC_INFO,
- "We don't support this.");
- /* Fallthrough. */
- }
+ qFatal("%s: QXmlStreamReader::EntityReference token is not supported", Q_FUNC_INFO);
+ break;
case QXmlStreamReader::NoToken:
/* Fallthrough. */
case QXmlStreamReader::Invalid:
{
- qWarning(qPrintable(reader.errorString()));
+ qWarning("%s", qPrintable(reader.errorString()));
m_result.clear();
return;
}
@@ -346,7 +351,7 @@ void Loader::load()
if(reader.hasError())
{
- qWarning(qPrintable(reader.errorString()));
+ qWarning("%s", qPrintable(reader.errorString()));
m_result.clear();
}
}
@@ -355,6 +360,11 @@ QAbstractXmlNodeModel::Ptr LoadingModel::create(const QXmlNamePool &np)
{
Loader loader(np);
loader.load();
+ if (loader.m_result.isEmpty()) {
+ qWarning("%s: attempt to create model with no content", Q_FUNC_INFO);
+ return Ptr(0);
+ }
+
return Ptr(new LoadingModel(loader.m_result, np));
}
#endif //QTEST_XMLPATTERNS
diff --git a/tests/auto/qaccessibility/qaccessibility.pro b/tests/auto/qaccessibility/qaccessibility.pro
index a4f606c..71d6f95 100644
--- a/tests/auto/qaccessibility/qaccessibility.pro
+++ b/tests/auto/qaccessibility/qaccessibility.pro
@@ -1,4 +1,5 @@
load(qttest_p4)
+requires(contains(QT_CONFIG,accessibility))
SOURCES += tst_qaccessibility.cpp
unix:!mac:LIBS+=-lm
@@ -8,4 +9,4 @@ wince*: {
accessneeded.files = $$QT_BUILD_TREE\\plugins\\accessible\\*.dll
accessneeded.path = accessible
DEPLOYMENT += accessneeded
-} \ No newline at end of file
+}
diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp
index ad46812..92e3a8b 100644
--- a/tests/auto/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp
@@ -326,69 +326,16 @@ QString eventName(const int ev)
}
}
-static QString stateNames(int state)
-{
- QString stateString;
- if (state == 0x00000000) stateString += " Normal";
- if (state & 0x00000001) stateString += " Unavailable";
- if (state & 0x00000002) stateString += " Selected";
- if (state & 0x00000004) stateString += " Focused";
- if (state & 0x00000008) stateString += " Pressed";
- if (state & 0x00000010) stateString += " Checked";
- if (state & 0x00000020) stateString += " Mixed";
- if (state & 0x00000040) stateString += " ReadOnly";
- if (state & 0x00000080) stateString += " HotTracked";
- if (state & 0x00000100) stateString += " DefaultButton";
- if (state & 0x00000200) stateString += " Expanded";
- if (state & 0x00000400) stateString += " Collapsed";
- if (state & 0x00000800) stateString += " Busy";
- if (state & 0x00001000) stateString += " Floating";
- if (state & 0x00002000) stateString += " Marqueed";
- if (state & 0x00004000) stateString += " Animated";
- if (state & 0x00008000) stateString += " Invisible";
- if (state & 0x00010000) stateString += " Offscreen";
- if (state & 0x00020000) stateString += " Sizeable";
- if (state & 0x00040000) stateString += " Moveable";
- if (state & 0x00080000) stateString += " SelfVoicing";
- if (state & 0x00100000) stateString += " Focusable";
- if (state & 0x00200000) stateString += " Selectable";
- if (state & 0x00400000) stateString += " Linked";
- if (state & 0x00800000) stateString += " Traversed";
- if (state & 0x01000000) stateString += " MultiSelectable";
- if (state & 0x02000000) stateString += " ExtSelectable";
- if (state & 0x04000000) stateString += " AlertLow";
- if (state & 0x08000000) stateString += " AlertMedium";
- if (state & 0x10000000) stateString += " AlertHigh";
- if (state & 0x20000000) stateString += " Protected";
- if (state & 0x3fffffff) stateString += " Valid";
-
- if (stateString.isEmpty())
- stateString = "Unknown state " + QString::number(state);
-
- return stateString;
-}
-
QAccessible::State state(QWidget * const widget)
{
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(widget);
- Q_ASSERT(iface);
- QAccessible::State state = iface->state(0);
+ if (!iface)
+ qWarning() << "Cannot get QAccessibleInterface for widget";
+ QAccessible::State state = (iface ? iface->state(0) : static_cast<QAccessible::State>(0));
delete iface;
return state;
}
-void printState(QWidget * const widget)
-{
- qDebug() << "State for" << widget->metaObject()->className() << stateNames(state(widget));
-}
-
-void printState(QAccessibleInterface * const iface, const int child = 0)
-{
- qDebug() << "State for" << iface->object()->metaObject()->className() << "child" << child
- << iface->text(QAccessible::Name, child) << stateNames(iface->state(child));
-}
-
-
class QtTestAccessibleWidget: public QWidget
{
Q_OBJECT
@@ -403,7 +350,6 @@ public:
}
};
-#ifdef QTEST_ACCESSIBILITY
class QtTestAccessibleWidgetIface: public QAccessibleWidget
{
public:
@@ -421,7 +367,6 @@ public:
return 0;
}
};
-#endif
tst_QAccessibility::tst_QAccessibility()
{
@@ -433,17 +378,13 @@ tst_QAccessibility::~tst_QAccessibility()
void tst_QAccessibility::initTestCase()
{
-#ifdef QTEST_ACCESSIBILITY
QTestAccessibility::initialize();
QAccessible::installFactory(QtTestAccessibleWidgetIface::ifaceFactory);
-#endif
}
void tst_QAccessibility::cleanupTestCase()
{
-#ifdef QTEST_ACCESSIBILITY
QTestAccessibility::cleanup();
-#endif
}
void tst_QAccessibility::init()
@@ -453,7 +394,6 @@ void tst_QAccessibility::init()
void tst_QAccessibility::cleanup()
{
-#ifdef QTEST_ACCESSIBILITY
const EventList list = QTestAccessibility::events();
if (!list.isEmpty()) {
qWarning("%d accessibility event(s) were not handled in testfunction '%s':", list.count(),
@@ -463,14 +403,10 @@ void tst_QAccessibility::cleanup()
eventName(list.at(i).event).toAscii().constData(), list.at(i).event, list.at(i).child);
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::eventTest()
{
-#ifdef QTEST_ACCESSIBILITY
QPushButton* button = new QPushButton(0);
button->setObjectName(QString("Olaf"));
@@ -491,14 +427,10 @@ void tst_QAccessibility::eventTest()
QVERIFY_EVENT(button, 0, QAccessible::ObjectHide);
delete button;
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::customWidget()
{
-#ifdef QTEST_ACCESSIBILITY
QtTestAccessibleWidget* widget = new QtTestAccessibleWidget(0, "Heinz");
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(widget);
@@ -510,14 +442,10 @@ void tst_QAccessibility::customWidget()
delete iface;
delete widget;
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::deletedWidget()
{
-#ifdef QTEST_ACCESSIBILITY
QtTestAccessibleWidget *widget = new QtTestAccessibleWidget(0, "Ralf");
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(widget);
QVERIFY(iface != 0);
@@ -528,9 +456,6 @@ void tst_QAccessibility::deletedWidget()
widget = 0;
QVERIFY(!iface->isValid());
delete iface;
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
QWidget *tst_QAccessibility::createGUI()
@@ -539,7 +464,6 @@ QWidget *tst_QAccessibility::createGUI()
qWarning( "Should never get here without Qt3Support");
return 0;
#else
-# ifdef QTEST_ACCESSIBILITY
QWidget *toplevel = new QWidget(0, Qt::X11BypassWindowManagerHint);
QGridLayout *grid = new QGridLayout(toplevel, 2, 2);
@@ -611,10 +535,6 @@ QWidget *tst_QAccessibility::createGUI()
radioAM->setFocus();
QTestAccessibility::clearEvents();
return toplevel;
-# else
- Q_ASSERT(0); // this function cannot be called without accessibility support
- return 0;
-# endif
#endif // !QT3_SUPPORT
}
@@ -623,7 +543,6 @@ void tst_QAccessibility::childAt()
#if !defined(QT3_SUPPORT)
QSKIP("This test needs Qt3Support", SkipAll);
#else
-#ifdef QTEST_ACCESSIBILITY
QWidget *toplevel = createGUI();
QAccessibleInterface *acc_toplevel = QAccessible::queryAccessibleInterface(toplevel);
QVERIFY(acc_toplevel);
@@ -655,9 +574,6 @@ void tst_QAccessibility::childAt()
delete acc_toplevel;
delete toplevel;
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
#endif // !QT3_SUPPORT
}
@@ -666,7 +582,6 @@ void tst_QAccessibility::childCount()
#if !defined(QT3_SUPPORT)
QSKIP("This test needs Qt3Support", SkipAll);
#else
-#ifdef QTEST_ACCESSIBILITY
QWidget *toplevel = createGUI();
QObject *topLeft = toplevel->child("topLeft");
QObject *topRight = toplevel->child("topRight");
@@ -699,9 +614,6 @@ void tst_QAccessibility::childCount()
delete acc_bottomRight;
delete toplevel;
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
#endif // !QT3_SUPPORT
}
@@ -710,7 +622,6 @@ void tst_QAccessibility::relationTo()
#if !defined(QT3_SUPPORT)
QSKIP("This test needs Qt3Support", SkipAll);
#else
-#ifdef QTEST_ACCESSIBILITY
QWidget *toplevel = createGUI();
toplevel->resize(400,300);
QObject *topLeft = toplevel->child("topLeft");
@@ -916,15 +827,11 @@ void tst_QAccessibility::relationTo()
delete toplevel;
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
#endif // !QT3_SUPPORT
}
void tst_QAccessibility::navigateGeometric()
{
-#ifdef QTEST_ACCESSIBILITY
{
static const int skip = 20; //speed the test up significantly
static const double step = Q_PI / 180;
@@ -1020,14 +927,10 @@ void tst_QAccessibility::navigateGeometric()
delete w;
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::navigateSlider()
{
-#ifdef QTEST_ACCESSIBILITY
{
QSlider *slider = new QSlider(0);
slider->setObjectName(QString("Slidy"));
@@ -1054,14 +957,10 @@ void tst_QAccessibility::navigateSlider()
delete slider;
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::navigateCovered()
{
-#ifdef QTEST_ACCESSIBILITY
{
QWidget *w = new QWidget(0);
w->setObjectName(QString("Harry"));
@@ -1164,14 +1063,10 @@ void tst_QAccessibility::navigateCovered()
delete w;
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::navigateHierarchy()
{
-#ifdef QTEST_ACCESSIBILITY
{
QWidget *w = new QWidget(0);
w->setObjectName(QString("Hans"));
@@ -1267,9 +1162,6 @@ void tst_QAccessibility::navigateHierarchy()
delete w;
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
#define QSETCOMPARE(thetypename, elements, otherelements) \
@@ -1280,7 +1172,6 @@ void tst_QAccessibility::navigateControllers()
#if !defined(QT3_SUPPORT)
QSKIP("This test needs Qt3Support", SkipAll);
#else
-#ifdef QTEST_ACCESSIBILITY
{
Q3VBox vbox;
QSlider slider(&vbox);
@@ -1363,9 +1254,6 @@ void tst_QAccessibility::navigateControllers()
delete acc_slider;
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
#endif // !QT3_SUPPORT
}
@@ -1374,7 +1262,6 @@ void tst_QAccessibility::navigateLabels()
#if !defined(QT3_SUPPORT)
QSKIP("This test needs Qt3Support", SkipAll);
#else
-#ifdef QTEST_ACCESSIBILITY
{
Q3VBox vbox;
Q3HBox hbox(&vbox);
@@ -1496,9 +1383,6 @@ void tst_QAccessibility::navigateLabels()
delete acc_lineedit3;
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
#endif // !QT3_SUPPORT
}
@@ -1550,7 +1434,6 @@ static QWidget *createWidgets()
void tst_QAccessibility::accessibleName()
{
-#ifdef QTEST_ACCESSIBILITY
QWidget *toplevel = createWidgets();
toplevel->show();
#if defined(Q_WS_X11)
@@ -1575,9 +1458,6 @@ void tst_QAccessibility::accessibleName()
delete toplevel;
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::text()
@@ -1585,7 +1465,6 @@ void tst_QAccessibility::text()
#if !defined(QT3_SUPPORT)
QSKIP("This test needs Qt3Support", SkipAll);
#else
-#ifdef QTEST_ACCESSIBILITY
QWidget *toplevel = createGUI();
toplevel->show();
#if defined(Q_WS_X11)
@@ -1681,10 +1560,6 @@ void tst_QAccessibility::text()
delete toplevel;
QTestAccessibility::clearEvents();
-
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
#endif // !QT3_SUPPORT
}
@@ -1693,7 +1568,6 @@ void tst_QAccessibility::setText()
#if !defined(QT3_SUPPORT)
QSKIP("This test needs Qt3Support", SkipAll);
#else
-#ifdef QTEST_ACCESSIBILITY
QWidget *toplevel = createGUI();
toplevel->show();
QObject *bottomLeft = toplevel->findChild<QObject *>("bottomLeft");
@@ -1717,16 +1591,11 @@ void tst_QAccessibility::setText()
delete acc_lineedit;
delete toplevel;
QTestAccessibility::clearEvents();
-
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
#endif //QT3_SUPPORT
}
void tst_QAccessibility::hideShowTest()
{
-#ifdef QTEST_ACCESSIBILITY
QWidget * const window = new QWidget();
QWidget * const child = new QWidget(window);
@@ -1753,14 +1622,10 @@ void tst_QAccessibility::hideShowTest()
delete window;
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::userActionCount()
{
-#ifdef QTEST_ACCESSIBILITY
QWidget widget;
QAccessibleInterface *test = QAccessible::queryAccessibleInterface(&widget);
@@ -1790,18 +1655,14 @@ void tst_QAccessibility::userActionCount()
QCOMPARE(test->userActionCount(1), 0);
QCOMPARE(test->userActionCount(-1), 0);
delete test; test = 0;
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::actionText()
{
-#ifdef QTEST_ACCESSIBILITY
- QWidget widget;
- widget.show();
+ QWidget *widget = new QWidget;
+ widget->show();
- QAccessibleInterface *test = QAccessible::queryAccessibleInterface(&widget);
+ QAccessibleInterface *test = QAccessible::queryAccessibleInterface(widget);
QVERIFY(test);
QVERIFY(test->isValid());
@@ -1813,39 +1674,29 @@ void tst_QAccessibility::actionText()
QCOMPARE(test->actionText(QAccessible::DefaultAction, QAccessible::Name, 0), QString("SetFocus"));
QCOMPARE(test->actionText(QAccessible::SetFocus, QAccessible::Name, 0), QString("SetFocus"));
- delete test; test = 0;
+ delete test;
+ delete widget;
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
+ QTestAccessibility::clearEvents();
}
void tst_QAccessibility::doAction()
{
-#ifdef QTEST_ACCESSIBILITY
QSKIP("TODO: Implement me", SkipAll);
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::applicationTest()
{
-#ifdef QTEST_ACCESSIBILITY
QLatin1String name = QLatin1String("My Name");
qApp->setApplicationName(name);
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(qApp);
QCOMPARE(interface->text(QAccessible::Name, 0), name);
QCOMPARE(interface->role(0), QAccessible::Application);
delete interface;
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::mainWindowTest()
{
-#ifdef QTEST_ACCESSIBILITY
QMainWindow mw;
mw.resize(300, 200);
mw.show(); // triggers layout
@@ -1858,10 +1709,6 @@ void tst_QAccessibility::mainWindowTest()
QCOMPARE(interface->text(QAccessible::Name, 0), name);
QCOMPARE(interface->role(0), QAccessible::Window);
delete interface;
-
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
class CounterButton : public QPushButton {
@@ -1881,7 +1728,6 @@ public Q_SLOTS:
void tst_QAccessibility::buttonTest()
{
-#ifdef QTEST_ACCESSIBILITY
QWidget window;
window.setLayout(new QVBoxLayout);
@@ -2070,10 +1916,6 @@ void tst_QAccessibility::buttonTest()
// test->release();
QTestAccessibility::clearEvents();
-
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::sliderTest()
@@ -2081,20 +1923,19 @@ void tst_QAccessibility::sliderTest()
#if !defined(QT3_SUPPORT)
QSKIP("This test needs Qt3Support", SkipAll);
#else
-#ifdef QTEST_ACCESSIBILITY
QAccessibleInterface *test = 0;
- Q3VBox vbox;
- QLabel labelHorizontal("Horizontal", &vbox);
- QSlider sliderHorizontal(Qt::Horizontal, &vbox);
- labelHorizontal.setBuddy(&sliderHorizontal);
+ Q3VBox *vbox = new Q3VBox;
+ QLabel *labelHorizontal = new QLabel("Horizontal", vbox);
+ QSlider *sliderHorizontal = new QSlider(Qt::Horizontal, vbox);
+ labelHorizontal->setBuddy(sliderHorizontal);
- QLabel labelVertical("Vertical", &vbox);
- QSlider sliderVertical(Qt::Vertical, &vbox);
- labelVertical.setBuddy(&sliderVertical);
- vbox.show();
+ QLabel *labelVertical = new QLabel("Vertical", vbox);
+ QSlider *sliderVertical = new QSlider(Qt::Vertical, vbox);
+ labelVertical->setBuddy(sliderVertical);
+ vbox->show();
// test horizontal slider
- test = QAccessible::queryAccessibleInterface(&sliderHorizontal);
+ test = QAccessible::queryAccessibleInterface(sliderHorizontal);
QVERIFY(test);
QCOMPARE(test->childCount(), 3);
QCOMPARE(test->role(0), QAccessible::Slider);
@@ -2102,15 +1943,15 @@ void tst_QAccessibility::sliderTest()
QCOMPARE(test->role(2), QAccessible::Indicator);
QCOMPARE(test->role(3), QAccessible::PushButton);
- QCOMPARE(test->text(QAccessible::Name, 0), labelHorizontal.text());
+ QCOMPARE(test->text(QAccessible::Name, 0), labelHorizontal->text());
QCOMPARE(test->text(QAccessible::Name, 1), QSlider::tr("Page left"));
QCOMPARE(test->text(QAccessible::Name, 2), QSlider::tr("Position"));
QCOMPARE(test->text(QAccessible::Name, 3), QSlider::tr("Page right"));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal.value()));
+ QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->value()));
QCOMPARE(test->text(QAccessible::Value, 1), QString());
- QCOMPARE(test->text(QAccessible::Value, 2), QString::number(sliderHorizontal.value()));
+ QCOMPARE(test->text(QAccessible::Value, 2), QString::number(sliderHorizontal->value()));
QCOMPARE(test->text(QAccessible::Value, 3), QString());
-// Skip acton tests.
+// Skip action tests.
#if 0
QCOMPARE(test->defaultAction(0), QAccessible::SetFocus);
QCOMPARE(test->defaultAction(1), QAccessible::Press);
@@ -2122,26 +1963,26 @@ void tst_QAccessibility::sliderTest()
QCOMPARE(test->actionText(QAccessible::Decrease, QAccessible::Name, 2), QSlider::tr("Decrease"));
QCOMPARE(test->actionText(QAccessible::Press, QAccessible::Name, 3), QSlider::tr("Press"));
QVERIFY(test->doAction(QAccessible::Press, 3));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal.pageStep()));
+ QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->pageStep()));
QVERIFY(test->doAction(QAccessible::Press, 3));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderHorizontal.pageStep()));
+ QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderHorizontal->pageStep()));
QVERIFY(test->doAction(QAccessible::Press, 1));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal.pageStep()));
+ QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->pageStep()));
QVERIFY(test->doAction(QAccessible::Press, 1));
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(0));
QVERIFY(test->doAction(QAccessible::Increase, 2));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal.lineStep()));
+ QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->lineStep()));
QVERIFY(test->doAction(QAccessible::Increase, 2));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderHorizontal.lineStep()));
+ QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderHorizontal->lineStep()));
QVERIFY(test->doAction(QAccessible::Decrease, 2));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal.lineStep()));
+ QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->lineStep()));
QVERIFY(test->doAction(QAccessible::Decrease, 2));
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(0));
#endif
delete test;
// test vertical slider
- test = QAccessible::queryAccessibleInterface(&sliderVertical);
+ test = QAccessible::queryAccessibleInterface(sliderVertical);
QVERIFY(test);
QCOMPARE(test->childCount(), 3);
QCOMPARE(test->role(0), QAccessible::Slider);
@@ -2149,15 +1990,15 @@ void tst_QAccessibility::sliderTest()
QCOMPARE(test->role(2), QAccessible::Indicator);
QCOMPARE(test->role(3), QAccessible::PushButton);
- QCOMPARE(test->text(QAccessible::Name, 0), labelVertical.text());
+ QCOMPARE(test->text(QAccessible::Name, 0), labelVertical->text());
QCOMPARE(test->text(QAccessible::Name, 1), QSlider::tr("Page up"));
QCOMPARE(test->text(QAccessible::Name, 2), QSlider::tr("Position"));
QCOMPARE(test->text(QAccessible::Name, 3), QSlider::tr("Page down"));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical.value()));
+ QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->value()));
QCOMPARE(test->text(QAccessible::Value, 1), QString());
- QCOMPARE(test->text(QAccessible::Value, 2), QString::number(sliderVertical.value()));
+ QCOMPARE(test->text(QAccessible::Value, 2), QString::number(sliderVertical->value()));
QCOMPARE(test->text(QAccessible::Value, 3), QString());
-// Skip acton tests.
+// Skip action tests.
#if 0
QCOMPARE(test->defaultAction(0), QAccessible::SetFocus);
QCOMPARE(test->defaultAction(1), QAccessible::Press);
@@ -2169,23 +2010,28 @@ void tst_QAccessibility::sliderTest()
QCOMPARE(test->actionText(QAccessible::Decrease, QAccessible::Name, 2), QSlider::tr("Decrease"));
QCOMPARE(test->actionText(QAccessible::Press, QAccessible::Name, 3), QSlider::tr("Press"));
QVERIFY(test->doAction(QAccessible::Press, 3));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical.pageStep()));
+ QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->pageStep()));
QVERIFY(test->doAction(QAccessible::Press, 3));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderVertical.pageStep()));
+ QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderVertical->pageStep()));
QVERIFY(test->doAction(QAccessible::Press, 1));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical.pageStep()));
+ QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->pageStep()));
QVERIFY(test->doAction(QAccessible::Press, 1));
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(0));
QVERIFY(test->doAction(QAccessible::Increase, 2));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical.lineStep()));
+ QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->lineStep()));
QVERIFY(test->doAction(QAccessible::Increase, 2));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderVertical.lineStep()));
+ QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderVertical->lineStep()));
QVERIFY(test->doAction(QAccessible::Decrease, 2));
- QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical.lineStep()));
+ QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->lineStep()));
QVERIFY(test->doAction(QAccessible::Decrease, 2));
QCOMPARE(test->text(QAccessible::Value, 0), QString::number(0));
#endif
delete test;
+ delete sliderHorizontal;
+ delete sliderVertical;
+ delete labelHorizontal;
+ delete labelVertical;
+ delete vbox;
// Test that when we hide() a slider, the PageLeft, Indicator, and PageRight also gets the
// Invisible state bit set.
@@ -2268,17 +2114,12 @@ void tst_QAccessibility::sliderTest()
delete sliderInterface;
}
-
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
#endif //!QT3_SUPPORT
}
void tst_QAccessibility::scrollBarTest()
{
-#ifdef QTEST_ACCESSIBILITY
// Test that when we hide() a slider, the PageLeft, Indicator, and PageRight also gets the
// Invisible state bit set.
enum SubControls { LineUp = 1,
@@ -2286,7 +2127,7 @@ void tst_QAccessibility::scrollBarTest()
Position = 3,
PageDown = 4,
LineDown = 5
- };
+ };
QScrollBar *scrollBar = new QScrollBar();
QAccessibleInterface * const scrollBarInterface = QAccessible::queryAccessibleInterface(scrollBar);
@@ -2368,15 +2209,10 @@ void tst_QAccessibility::scrollBarTest()
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
-
}
void tst_QAccessibility::tabTest()
{
-#ifdef QTEST_ACCESSIBILITY
QTabBar *tabBar = new QTabBar();
tabBar->show();
@@ -2412,14 +2248,10 @@ void tst_QAccessibility::tabTest()
delete tabBar;
delete interface;
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::tabWidgetTest()
{
-#ifdef QTEST_ACCESSIBILITY
QTabWidget *tabWidget = new QTabWidget();
tabWidget->show();
@@ -2505,14 +2337,10 @@ void tst_QAccessibility::tabWidgetTest()
delete interface;
delete tabWidget;
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::menuTest()
{
-#ifdef QTEST_ACCESSIBILITY
{
QMainWindow mw;
mw.resize(300, 200);
@@ -2758,14 +2586,10 @@ void tst_QAccessibility::menuTest()
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::spinBoxTest()
{
-#ifdef QTEST_ACCESSIBILITY
QSpinBox * const spinBox = new QSpinBox();
spinBox->show();
@@ -2792,14 +2616,10 @@ void tst_QAccessibility::spinBoxTest()
QVERIFY(events.contains(expectedEvent));
delete spinBox;
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::doubleSpinBoxTest()
{
-#ifdef QTEST_ACCESSIBILITY
QDoubleSpinBox *doubleSpinBox = new QDoubleSpinBox;
doubleSpinBox->show();
@@ -2819,14 +2639,10 @@ void tst_QAccessibility::doubleSpinBoxTest()
delete doubleSpinBox;
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::textEditTest()
{
-#ifdef QTEST_ACCESSIBILITY
{
QTextEdit edit;
QString text = "hello world\nhow are you today?\n";
@@ -2846,14 +2662,10 @@ void tst_QAccessibility::textEditTest()
QCOMPARE(iface->textInterface()->characterRect(6, QAccessible2::RelativeToParent).size(), QSize(fm.width("w"), fm.height()));
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::textBrowserTest()
{
-#ifdef QTEST_ACCESSIBILITY
{
QTextBrowser textBrowser;
QString text = QLatin1String("Hello world\nhow are you today?\n");
@@ -2870,14 +2682,10 @@ void tst_QAccessibility::textBrowserTest()
QCOMPARE(interface->text(QAccessible::Value, 6), QString());
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::listViewTest()
{
-#if 1 //def QTEST_ACCESSIBILITY
{
QListView listView;
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(&listView);
@@ -2943,15 +2751,11 @@ void tst_QAccessibility::listViewTest()
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::mdiAreaTest()
{
-#ifdef QTEST_ACCESSIBILITY
{
QMdiArea mdiArea;
mdiArea.resize(400,300);
@@ -3000,14 +2804,10 @@ void tst_QAccessibility::mdiAreaTest()
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::mdiSubWindowTest()
{
-#ifdef QTEST_ACCESSIBILITY
{
QMdiArea mdiArea;
mdiArea.show();
@@ -3130,14 +2930,10 @@ void tst_QAccessibility::mdiSubWindowTest()
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::lineEditTest()
{
-#ifdef QTEST_ACCESSIBILITY
QLineEdit *le = new QLineEdit;
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(le);
QVERIFY(iface);
@@ -3195,14 +2991,10 @@ void tst_QAccessibility::lineEditTest()
delete le2;
delete toplevel;
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::workspaceTest()
{
-#ifdef QTEST_ACCESSIBILITY
{
QWorkspace workspace;
workspace.resize(400,300);
@@ -3256,14 +3048,10 @@ void tst_QAccessibility::workspaceTest()
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::dialogButtonBoxTest()
{
-#ifdef QTEST_ACCESSIBILITY
{
QDialogButtonBox box(QDialogButtonBox::Reset |
QDialogButtonBox::Help |
@@ -3376,14 +3164,10 @@ void tst_QAccessibility::dialogButtonBoxTest()
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::dialTest()
{
-#ifdef QTEST_ACCESSIBILITY
{
QDial dial;
dial.setValue(20);
@@ -3425,28 +3209,20 @@ void tst_QAccessibility::dialTest()
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::rubberBandTest()
{
-#ifdef QTEST_ACCESSIBILITY
QRubberBand rubberBand(QRubberBand::Rectangle);
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&rubberBand);
QVERIFY(interface);
QCOMPARE(interface->role(0), QAccessible::Border);
delete interface;
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::abstractScrollAreaTest()
{
-#ifdef QTEST_ACCESSIBILITY
{
QAbstractScrollArea abstractScrollArea;
@@ -3604,14 +3380,10 @@ void tst_QAccessibility::abstractScrollAreaTest()
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::scrollAreaTest()
{
-#ifdef QTEST_ACCESSIBILITY
{
QScrollArea scrollArea;
scrollArea.show();
@@ -3625,14 +3397,10 @@ void tst_QAccessibility::scrollAreaTest()
delete interface;
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::tableWidgetTest()
{
-#ifdef QTEST_ACCESSIBILITY
{
QWidget *topLevel = new QWidget;
QTableWidget *w = new QTableWidget(8,4,topLevel);
@@ -3672,10 +3440,6 @@ void tst_QAccessibility::tableWidgetTest()
delete topLevel;
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
-
}
class QtTestTableModel: public QAbstractTableModel
@@ -3758,7 +3522,6 @@ public:
void tst_QAccessibility::tableViewTest()
{
-#ifdef QTEST_ACCESSIBILITY
{
QtTestTableModel *model = new QtTestTableModel(3, 4);
QTableView *w = new QTableView();
@@ -3838,15 +3601,11 @@ void tst_QAccessibility::tableViewTest()
delete model;
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::calendarWidgetTest()
{
#ifndef QT_NO_CALENDARWIDGET
-#ifdef QTEST_ACCESSIBILITY
{
QCalendarWidget calendarWidget;
@@ -3939,17 +3698,12 @@ void tst_QAccessibility::calendarWidgetTest()
}
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
#endif // QT_NO_CALENDARWIDGET
}
void tst_QAccessibility::dockWidgetTest()
{
#ifndef QT_NO_DOCKWIDGET
-
-#ifdef QTEST_ACCESSIBILITY
// Set up a proper main window with two dock widgets
QMainWindow *mw = new QMainWindow();
QFrame *central = new QFrame(mw);
@@ -4017,19 +3771,14 @@ void tst_QAccessibility::dockWidgetTest()
delete dock2;
delete mw;
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
#endif // QT_NO_DOCKWIDGET
}
void tst_QAccessibility::pushButtonTest()
{
#if !defined(QT3_SUPPORT)
- qWarning( "Should never get here without Qt3Support");
- return ;
+ QSKIP( "Should never get here without Qt3Support", SkipAll);
#else
-#ifdef QTEST_ACCESSIBILITY
// Set up a proper main window with two dock widgets
QWidget *toplevel = createGUI();
QObject *topRight = toplevel->findChild<QObject *>("topRight");
@@ -4063,15 +3812,11 @@ void tst_QAccessibility::pushButtonTest()
delete accToplevel;
delete toplevel;
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
#endif //QT3_SUPPORT
}
void tst_QAccessibility::comboBoxTest()
{
-#ifdef QTEST_ACCESSIBILITY
#if defined(Q_OS_WINCE)
if (!IsValidCEPlatform()) {
QSKIP("Test skipped on Windows Mobile test hardware", SkipAll);
@@ -4109,15 +3854,10 @@ void tst_QAccessibility::comboBoxTest()
delete w;
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
-
}
void tst_QAccessibility::treeWidgetTest()
{
-#ifdef QTEST_ACCESSIBILITY
QWidget *w = new QWidget;
QTreeWidget *tree = new QTreeWidget(w);
QHBoxLayout *l = new QHBoxLayout(w);
@@ -4175,14 +3915,10 @@ void tst_QAccessibility::treeWidgetTest()
delete w;
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::labelTest()
{
-#ifdef QTEST_ACCESSIBILITY
QString text = "Hello World";
QLabel *label = new QLabel(text);
label->show();
@@ -4221,14 +3957,10 @@ void tst_QAccessibility::labelTest()
delete acc_label;
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs accessibility support.", SkipAll);
-#endif
}
void tst_QAccessibility::accelerators()
{
-#ifdef QTEST_ACCESSIBILITY
QWidget *window = new QWidget;
QHBoxLayout *lay = new QHBoxLayout(window);
QLabel *label = new QLabel(tr("&Line edit"), window);
@@ -4252,6 +3984,10 @@ void tst_QAccessibility::accelerators()
QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + QLatin1String("A"));
label->setText(tr("Q &&A"));
QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QString());
+
+#if !defined(QT_NO_DEBUG) && !defined(Q_WS_MAC)
+ QTest::ignoreMessage(QtWarningMsg, "QKeySequence::mnemonic: \"Q &A&B\" contains multiple occurrences of '&'");
+#endif
label->setText(tr("Q &A&B"));
QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + QLatin1String("A"));
@@ -4261,9 +3997,6 @@ void tst_QAccessibility::accelerators()
QTest::qWait(100);
delete window;
QTestAccessibility::clearEvents();
-#else
- QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll);
-#endif
}
diff --git a/tests/auto/qalgorithms/tst_qalgorithms.cpp b/tests/auto/qalgorithms/tst_qalgorithms.cpp
index fe8fb1a..1513c98 100644
--- a/tests/auto/qalgorithms/tst_qalgorithms.cpp
+++ b/tests/auto/qalgorithms/tst_qalgorithms.cpp
@@ -241,7 +241,8 @@ QList<ResultSet> testAlgorithm(Algorithm &algorithm, QStringList dataSetTypes,
foreach(QString dataSetType, dataSetTypes) {
QVector<DataType> container = generateData<DataType>(dataSetType, size);
results.append(testRun(container, algorithm, time));
- Q_ASSERT(isSorted(container));
+ if (!isSorted(container))
+ qWarning("%s: container is not sorted after test", Q_FUNC_INFO);
}
return results;
}
diff --git a/tests/auto/qatomicint/tst_qatomicint.cpp b/tests/auto/qatomicint/tst_qatomicint.cpp
index a683322..27a2cc2 100644
--- a/tests/auto/qatomicint/tst_qatomicint.cpp
+++ b/tests/auto/qatomicint/tst_qatomicint.cpp
@@ -116,8 +116,7 @@ tst_QAtomicInt::~tst_QAtomicInt()
void tst_QAtomicInt::warningFreeHelper()
{
- Q_ASSERT(false);
- // The code below is bogus, and shouldn't be run. We're looking for warnings, only.
+ qFatal("This code is bogus, and shouldn't be run. We're looking for compiler warnings only.");
QBasicAtomicInt i = Q_BASIC_ATOMIC_INITIALIZER(0);
diff --git a/tests/auto/qatomicpointer/tst_qatomicpointer.cpp b/tests/auto/qatomicpointer/tst_qatomicpointer.cpp
index 0e8aa6b..42e744a 100644
--- a/tests/auto/qatomicpointer/tst_qatomicpointer.cpp
+++ b/tests/auto/qatomicpointer/tst_qatomicpointer.cpp
@@ -98,8 +98,7 @@ struct WFHC
void tst_QAtomicPointer::warningFreeHelper()
{
- Q_ASSERT(false);
- // The code below is bogus, and shouldn't be run. We're looking for warnings, only.
+ qFatal("This code is bogus, and shouldn't be run. We're looking for compiler warnings only.");
QBasicAtomicPointer<WFHC> p = Q_BASIC_ATOMIC_INITIALIZER(0);
diff --git a/tests/auto/qbuffer/tst_qbuffer.cpp b/tests/auto/qbuffer/tst_qbuffer.cpp
index aee3b81..776935d 100644
--- a/tests/auto/qbuffer/tst_qbuffer.cpp
+++ b/tests/auto/qbuffer/tst_qbuffer.cpp
@@ -309,8 +309,7 @@ void tst_QBuffer::seekTest()
// (see Task 184730)
{
char c;
- const int offset = 1;
- Q_ASSERT(offset > 0); // any positive integer will do
+ const int offset = 1; // any positive integer will do
const qint64 pos = buf.size() + offset;
QVERIFY(buf.seek(pos));
QCOMPARE(buf.pos(), pos);
diff --git a/tests/auto/qchar/tst_qchar.cpp b/tests/auto/qchar/tst_qchar.cpp
index 54c3b90..1fdbc34 100644
--- a/tests/auto/qchar/tst_qchar.cpp
+++ b/tests/auto/qchar/tst_qchar.cpp
@@ -548,14 +548,14 @@ void tst_QChar::normalization_data()
QList<QByteArray> l = line.split(';');
- Q_ASSERT(l.size() == 5);
+ QCOMPARE(l.size(), 5);
QStringList columns;
for (int i = 0; i < 5; ++i) {
columns.append(QString());
QList<QByteArray> c = l.at(i).split(' ');
- Q_ASSERT(!c.isEmpty());
+ QVERIFY(!c.isEmpty());
for (int j = 0; j < c.size(); ++j) {
bool ok;
diff --git a/tests/auto/qcolor/tst_qcolor.cpp b/tests/auto/qcolor/tst_qcolor.cpp
index dc577dc..2b6896a 100644
--- a/tests/auto/qcolor/tst_qcolor.cpp
+++ b/tests/auto/qcolor/tst_qcolor.cpp
@@ -1506,7 +1506,6 @@ void tst_QColor::setallowX11ColorNames()
for (int i = 0; i < x11RgbTblSize; ++i) {
QString colorName = QLatin1String(x11RgbTbl[i].name);
QColor color;
- QTest::ignoreMessage(QtWarningMsg, QString("QColor::setNamedColor: Unknown color name '%1'").arg(colorName).toLatin1());
color.setNamedColor(colorName);
QVERIFY(!color.isValid());
}
@@ -1528,7 +1527,6 @@ void tst_QColor::setallowX11ColorNames()
for (int i = 0; i < x11RgbTblSize; ++i) {
QString colorName = QLatin1String(x11RgbTbl[i].name);
QColor color;
- QTest::ignoreMessage(QtWarningMsg, QString("QColor::setNamedColor: Unknown color name '%1'").arg(colorName).toLatin1());
color.setNamedColor(colorName);
QVERIFY(!color.isValid());
}
diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp
index 7c4fa9b..c1467c6 100644
--- a/tests/auto/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/qcompleter/tst_qcompleter.cpp
@@ -277,7 +277,9 @@ retry:
case 'L': row = completer->completionCount() - 1; break;
case 'F': row = 0; break;
default:
- Q_ASSERT(false);
+ QFAIL(qPrintable(QString(
+ "Problem with 'step' value in test data: %1 (only P, N, L and F are allowed)."
+ ).arg(step[i])));
}
completer->setCurrentRow(row);
}
@@ -1248,9 +1250,7 @@ public:
void tst_QCompleter::task189564_omitNonSelectableItems()
{
const QString prefix("a");
- Q_ASSERT(!prefix.isEmpty());
const int n = 5;
- Q_ASSERT(n > 0);
QStringList strings;
for (int i = 0; i < n; ++i)
@@ -1278,10 +1278,11 @@ public:
{
setEditable(true);
setInsertPolicy(NoInsert);
- Q_ASSERT(completer());
- completer()->setCompletionMode(QCompleter::PopupCompletion);
- completer()->setCompletionRole(Qt::DisplayRole);
- connect(lineEdit(), SIGNAL(editingFinished()), SLOT(setCompletionPrefix()));
+ if (completer()) {
+ completer()->setCompletionMode(QCompleter::PopupCompletion);
+ completer()->setCompletionRole(Qt::DisplayRole);
+ connect(lineEdit(), SIGNAL(editingFinished()), SLOT(setCompletionPrefix()));
+ }
}
private slots:
void setCompletionPrefix() { completer()->setCompletionPrefix(lineEdit()->text()); }
@@ -1290,6 +1291,7 @@ private slots:
void tst_QCompleter::task246056_setCompletionPrefix()
{
task246056_ComboBox *comboBox = new task246056_ComboBox;
+ QVERIFY(comboBox->completer());
comboBox->addItem("");
comboBox->addItem("a1");
comboBox->addItem("a2");
diff --git a/tests/auto/qcomplextext/tst_qcomplextext.cpp b/tests/auto/qcomplextext/tst_qcomplextext.cpp
index 25a0882..c72393c 100644
--- a/tests/auto/qcomplextext/tst_qcomplextext.cpp
+++ b/tests/auto/qcomplextext/tst_qcomplextext.cpp
@@ -214,7 +214,7 @@ void tst_QComplexText::bidiCursorMovement()
QTextOption option = layout.textOption();
option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft);
layout.setTextOption(option);
- layout.setCursorMoveStyle(QTextCursor::Visual);
+ layout.setCursorMoveStyle(Qt::VisualMoveStyle);
bool moved;
int oldPos, newPos = 0;
qreal x, newX;
diff --git a/tests/auto/qcopchannel/testSend/main.cpp b/tests/auto/qcopchannel/testSend/main.cpp
index 5a80cfa..ab5a421 100644
--- a/tests/auto/qcopchannel/testSend/main.cpp
+++ b/tests/auto/qcopchannel/testSend/main.cpp
@@ -49,7 +49,11 @@ int main(int argc, char** argv)
#ifdef Q_WS_QWS
QApplication app(argc, argv);
QStringList args = app.arguments();
- Q_ASSERT(args.count() == 3 || args.count() == 4);
+ if (args.count() != 3 && args.count() != 4) {
+ fprintf(stdout,qPrintable(QString("Usage: %1 channel message [data]").arg(args.at(0))));
+ fflush(stdout);
+ return 1;
+ }
QString channelName = args.at(1);
QString msg = args.at(2);
QByteArray data;
diff --git a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp
index b97c56f..c64c9e7 100644
--- a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp
+++ b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp
@@ -2701,17 +2701,10 @@ void tst_QDateTimeEdit::task98554()
QCOMPARE(testWidget->time(), QTime(0, 0, 10, 0));
}
-static QList<int> makeList(int val1, int val2 = -1, int val3 = -1, int val4 = -1, int val5 = -1, int val6 = -1, int val7 = -1)
+static QList<int> makeList(int val1, int val2, int val3)
{
QList<int> ret;
- Q_ASSERT(val1 >= 0);
- ret << val1;
- if (val2 < 0) {return ret;} else {ret << val2;}
- if (val3 < 0) {return ret;} else {ret << val3;}
- if (val4 < 0) {return ret;} else {ret << val4;}
- if (val5 < 0) {return ret;} else {ret << val5;}
- if (val6 < 0) {return ret;} else {ret << val6;}
- if (val7 >= 0) {ret << val2;}
+ ret << val1 << val2 << val3;
return ret;
}
@@ -2753,7 +2746,7 @@ void tst_QDateTimeEdit::setCurrentSection()
QFETCH(QList<int>, setCurrentSections);
QFETCH(QList<int>, expectedCursorPositions);
- Q_ASSERT(setCurrentSections.size() == expectedCursorPositions.size());
+ QCOMPARE(setCurrentSections.size(), expectedCursorPositions.size());
testWidget->setDisplayFormat(format);
testWidget->setDateTime(dateTime);
#ifdef Q_WS_MAC
diff --git a/tests/auto/qdbusthreading/tst_qdbusthreading.cpp b/tests/auto/qdbusthreading/tst_qdbusthreading.cpp
index f93d126..e37e4c3 100644
--- a/tests/auto/qdbusthreading/tst_qdbusthreading.cpp
+++ b/tests/auto/qdbusthreading/tst_qdbusthreading.cpp
@@ -592,7 +592,7 @@ void tst_QDBusThreading::callbackInAnotherAuxThread()
// wait for the event loop
sem1.release();
sem2.acquire();
- Q_ASSERT(loop);
+ QVERIFY(loop);
// create the second thread
new Thread;
diff --git a/tests/auto/qdirmodel/tst_qdirmodel.cpp b/tests/auto/qdirmodel/tst_qdirmodel.cpp
index 4e50a61..db424a2 100644
--- a/tests/auto/qdirmodel/tst_qdirmodel.cpp
+++ b/tests/auto/qdirmodel/tst_qdirmodel.cpp
@@ -641,10 +641,10 @@ void tst_QDirModel::filter()
QDirModel model;
model.setNameFilters(QStringList() << "*.nada");
QModelIndex index = model.index(SRCDIR "test");
- Q_ASSERT(model.rowCount(index) == 0);
+ QCOMPARE(model.rowCount(index), 0);
QModelIndex index2 = model.index(SRCDIR "test/file01.tst");
- Q_ASSERT(!index2.isValid());
- Q_ASSERT(model.rowCount(index) == 0);
+ QVERIFY(!index2.isValid());
+ QCOMPARE(model.rowCount(index), 0);
}
void tst_QDirModel::task244669_remove()
diff --git a/tests/auto/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp
index f30d3bc..4093010 100644
--- a/tests/auto/qdom/tst_qdom.cpp
+++ b/tests/auto/qdom/tst_qdom.cpp
@@ -137,7 +137,6 @@ private slots:
private:
static QDomDocument generateRequest();
- static QDomDocument doc(const QString &title, const QByteArray &ba);
static int hasAttributesHelper( const QDomNode& node );
static bool compareDocuments( const QDomDocument &doc1, const QDomDocument &doc2 );
static bool compareNodes( const QDomNode &node1, const QDomNode &node2, bool deep );
@@ -1591,14 +1590,6 @@ void tst_QDom::reportDuplicateAttributes() const
QVERIFY2(!isSuccess, "Duplicate attributes are well-formedness errors, and should be reported as such.");
}
-QDomDocument tst_QDom::doc(const QString &title, const QByteArray &ba)
-{
- QDomDocument doc(title);
- const bool ret = doc.setContent(ba, true);
- Q_ASSERT(ret);
- return doc;
-}
-
void tst_QDom::namespacedAttributes() const
{
static const char *const xml =
@@ -1611,8 +1602,13 @@ void tst_QDom::namespacedAttributes() const
" <Title displayLabel='Title' >>>> SIMPLE BASIC OP - SEND - DUT AS SINK</Title>\n"
"</xan:td>\n";
- QDomDocument one = doc("document", xml);
- QDomDocument two = doc("document2", one.toByteArray(2));
+ QDomDocument one("document");
+ QString error;
+ bool docParsed = one.setContent(QByteArray(xml), true, &error);
+ QVERIFY2(docParsed, qPrintable(error));
+ QDomDocument two("document2");
+ docParsed = two.setContent(one.toByteArray(2), true, &error);
+ QVERIFY2(docParsed, qPrintable(error));
QVERIFY(isDeepEqual(one, two));
}
diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp
index df1664f..bf6cc68 100644
--- a/tests/auto/qfile/largefile/tst_largefile.cpp
+++ b/tests/auto/qfile/largefile/tst_largefile.cpp
@@ -160,13 +160,10 @@ static inline void appendRaw(QByteArray &array, T data)
*/
static inline void topUpWith(QByteArray &array, QByteArray filler, int size)
{
- Q_ASSERT(filler.size() > 0);
-
for (int i = (size - array.size()) / filler.size(); i > 0; --i)
array.append(filler);
if (array.size() < size) {
- Q_ASSERT(size - array.size() < filler.size());
array.append(filler.left(size - array.size()));
}
}
@@ -206,15 +203,12 @@ static inline QByteArray generateDataBlock(int blockSize, QString text, qint64 u
QByteArray filler("0123456789");
block.append(filler.right(10 - block.size() % 10));
- topUpWith(block, filler, blockSize - 2 * sizeof(qint64));
+ topUpWith(block, filler, blockSize - 3 * sizeof(qint64));
appendRaw(block, counter);
appendRaw(block, userBits);
appendRaw(block, randomBits);
- Q_ASSERT( block.size() >= blockSize );
- block.resize(blockSize);
-
++counter;
return block;
}
diff --git a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp
index 59491f1..afa2e8f 100644
--- a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp
@@ -812,7 +812,7 @@ void tst_QFileDialog2::task239706_editableFilterCombo()
break;
}
}
- Q_ASSERT(filterCombo);
+ QVERIFY(filterCombo);
filterCombo->setEditable(true);
QTest::mouseClick(filterCombo, Qt::LeftButton);
QTest::keyPress(filterCombo, Qt::Key_X);
diff --git a/tests/auto/qglyphs/qglyphs.pro b/tests/auto/qglyphrun/qglyphrun.pro
index 5084cf9..480ad5b 100644
--- a/tests/auto/qglyphs/qglyphs.pro
+++ b/tests/auto/qglyphrun/qglyphrun.pro
@@ -2,10 +2,10 @@ load(qttest_p4)
QT = core gui
SOURCES += \
- tst_qglyphs.cpp
+ tst_qglyphrun.cpp
wince*|symbian*: {
DEFINES += SRCDIR=\\\"\\\"
} else {
DEFINES += SRCDIR=\\\"$$PWD/\\\"
-} \ No newline at end of file
+}
diff --git a/tests/auto/qglyphs/test.ttf b/tests/auto/qglyphrun/test.ttf
index 9043a57..9043a57 100644
--- a/tests/auto/qglyphs/test.ttf
+++ b/tests/auto/qglyphrun/test.ttf
Binary files differ
diff --git a/tests/auto/qglyphs/tst_qglyphs.cpp b/tests/auto/qglyphrun/tst_qglyphrun.cpp
index 8e4ed1a..3ea84e3 100644
--- a/tests/auto/qglyphs/tst_qglyphs.cpp
+++ b/tests/auto/qglyphrun/tst_qglyphrun.cpp
@@ -41,14 +41,14 @@
#include <QtTest/QtTest>
-#include <qglyphs.h>
+#include <qglyphrun.h>
#include <qpainter.h>
#include <qtextlayout.h>
#include <qfontdatabase.h>
// #define DEBUG_SAVE_IMAGE
-class tst_QGlyphs: public QObject
+class tst_QGlyphRun: public QObject
{
Q_OBJECT
@@ -82,9 +82,9 @@ private:
#if !defined(QT_NO_RAWFONT)
-Q_DECLARE_METATYPE(QGlyphs);
+Q_DECLARE_METATYPE(QGlyphRun);
-void tst_QGlyphs::initTestCase()
+void tst_QGlyphRun::initTestCase()
{
m_testFontId = QFontDatabase::addApplicationFont(SRCDIR "test.ttf");
QVERIFY(m_testFontId >= 0);
@@ -94,19 +94,19 @@ void tst_QGlyphs::initTestCase()
QCOMPARE(QFontInfo(m_testFont).family(), QString::fromLatin1("QtsSpecialTestFont"));
}
-void tst_QGlyphs::cleanupTestCase()
+void tst_QGlyphRun::cleanupTestCase()
{
QFontDatabase::removeApplicationFont(m_testFontId);
}
-void tst_QGlyphs::constructionAndDestruction()
+void tst_QGlyphRun::constructionAndDestruction()
{
- QGlyphs glyphIndexes;
+ QGlyphRun glyphIndexes;
}
-static QGlyphs make_dummy_indexes()
+static QGlyphRun make_dummy_indexes()
{
- QGlyphs glyphs;
+ QGlyphRun glyphs;
QVector<quint32> glyphIndexes;
QVector<QPointF> positions;
@@ -121,16 +121,16 @@ static QGlyphs make_dummy_indexes()
positions.append(QPointF(3, 4));
positions.append(QPointF(5, 6));
- glyphs.setFont(QRawFont::fromFont(font));
+ glyphs.setRawFont(QRawFont::fromFont(font));
glyphs.setGlyphIndexes(glyphIndexes);
glyphs.setPositions(positions);
return glyphs;
}
-void tst_QGlyphs::copyConstructor()
+void tst_QGlyphRun::copyConstructor()
{
- QGlyphs glyphs;
+ QGlyphRun glyphs;
{
QVector<quint32> glyphIndexes;
@@ -146,40 +146,40 @@ void tst_QGlyphs::copyConstructor()
positions.append(QPointF(3, 4));
positions.append(QPointF(5, 6));
- glyphs.setFont(QRawFont::fromFont(font));
+ glyphs.setRawFont(QRawFont::fromFont(font));
glyphs.setGlyphIndexes(glyphIndexes);
glyphs.setPositions(positions);
}
- QGlyphs otherGlyphs(glyphs);
- QCOMPARE(otherGlyphs.font(), glyphs.font());
+ QGlyphRun otherGlyphs(glyphs);
+ QCOMPARE(otherGlyphs.rawFont(), glyphs.rawFont());
QCOMPARE(glyphs.glyphIndexes(), otherGlyphs.glyphIndexes());
QCOMPARE(glyphs.positions(), otherGlyphs.positions());
}
-void tst_QGlyphs::assignment()
+void tst_QGlyphRun::assignment()
{
- QGlyphs glyphs(make_dummy_indexes());
+ QGlyphRun glyphs(make_dummy_indexes());
- QGlyphs otherGlyphs = glyphs;
- QCOMPARE(otherGlyphs.font(), glyphs.font());
+ QGlyphRun otherGlyphs = glyphs;
+ QCOMPARE(otherGlyphs.rawFont(), glyphs.rawFont());
QCOMPARE(glyphs.glyphIndexes(), otherGlyphs.glyphIndexes());
QCOMPARE(glyphs.positions(), otherGlyphs.positions());
}
-void tst_QGlyphs::equalsOperator_data()
+void tst_QGlyphRun::equalsOperator_data()
{
- QTest::addColumn<QGlyphs>("one");
- QTest::addColumn<QGlyphs>("two");
+ QTest::addColumn<QGlyphRun>("one");
+ QTest::addColumn<QGlyphRun>("two");
QTest::addColumn<bool>("equals");
- QGlyphs one(make_dummy_indexes());
- QGlyphs two(make_dummy_indexes());
+ QGlyphRun one(make_dummy_indexes());
+ QGlyphRun two(make_dummy_indexes());
QTest::newRow("Identical") << one << two << true;
{
- QGlyphs busted(two);
+ QGlyphRun busted(two);
QVector<QPointF> positions = busted.positions();
positions[2] += QPointF(1, 1);
@@ -190,17 +190,17 @@ void tst_QGlyphs::equalsOperator_data()
}
{
- QGlyphs busted(two);
+ QGlyphRun busted(two);
QFont font;
- font.setPixelSize(busted.font().pixelSize() * 2);
- busted.setFont(QRawFont::fromFont(font));
+ font.setPixelSize(busted.rawFont().pixelSize() * 2);
+ busted.setRawFont(QRawFont::fromFont(font));
QTest::newRow("Different fonts") << one << busted << false;
}
{
- QGlyphs busted(two);
+ QGlyphRun busted(two);
QVector<quint32> glyphIndexes = busted.glyphIndexes();
glyphIndexes[2] += 1;
@@ -211,10 +211,10 @@ void tst_QGlyphs::equalsOperator_data()
}
-void tst_QGlyphs::equalsOperator()
+void tst_QGlyphRun::equalsOperator()
{
- QFETCH(QGlyphs, one);
- QFETCH(QGlyphs, two);
+ QFETCH(QGlyphRun, one);
+ QFETCH(QGlyphRun, two);
QFETCH(bool, equals);
QCOMPARE(one == two, equals);
@@ -222,7 +222,7 @@ void tst_QGlyphs::equalsOperator()
}
-void tst_QGlyphs::textLayoutGlyphIndexes()
+void tst_QGlyphRun::textLayoutGlyphIndexes()
{
QString s;
s.append(QLatin1Char('A'));
@@ -234,17 +234,17 @@ void tst_QGlyphs::textLayoutGlyphIndexes()
layout.createLine();
layout.endLayout();
- QList<QGlyphs> listOfGlyphs = layout.glyphs();
+ QList<QGlyphRun> listOfGlyphs = layout.glyphRuns();
QCOMPARE(listOfGlyphs.size(), 1);
- QGlyphs glyphs = listOfGlyphs.at(0);
+ QGlyphRun glyphs = listOfGlyphs.at(0);
QCOMPARE(glyphs.glyphIndexes().size(), 2);
QCOMPARE(glyphs.glyphIndexes().at(0), quint32(2));
QCOMPARE(glyphs.glyphIndexes().at(1), quint32(1));
}
-void tst_QGlyphs::drawExistingGlyphs()
+void tst_QGlyphRun::drawExistingGlyphs()
{
QPixmap textLayoutDraw(1000, 1000);
QPixmap drawGlyphs(1000, 1000);
@@ -267,13 +267,13 @@ void tst_QGlyphs::drawExistingGlyphs()
layout.draw(&p, QPointF(50, 50));
}
- QGlyphs glyphs = layout.glyphs().size() > 0
- ? layout.glyphs().at(0)
- : QGlyphs();
+ QGlyphRun glyphs = layout.glyphRuns().size() > 0
+ ? layout.glyphRuns().at(0)
+ : QGlyphRun();
{
QPainter p(&drawGlyphs);
- p.drawGlyphs(QPointF(50, 50), glyphs);
+ p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -284,7 +284,7 @@ void tst_QGlyphs::drawExistingGlyphs()
QCOMPARE(textLayoutDraw, drawGlyphs);
}
-void tst_QGlyphs::drawNonExistentGlyphs()
+void tst_QGlyphRun::drawNonExistentGlyphs()
{
QVector<quint32> glyphIndexes;
glyphIndexes.append(3);
@@ -292,10 +292,10 @@ void tst_QGlyphs::drawNonExistentGlyphs()
QVector<QPointF> glyphPositions;
glyphPositions.append(QPointF(0, 0));
- QGlyphs glyphs;
+ QGlyphRun glyphs;
glyphs.setGlyphIndexes(glyphIndexes);
glyphs.setPositions(glyphPositions);
- glyphs.setFont(QRawFont::fromFont(m_testFont));
+ glyphs.setRawFont(QRawFont::fromFont(m_testFont));
QPixmap image(1000, 1000);
image.fill(Qt::white);
@@ -303,7 +303,7 @@ void tst_QGlyphs::drawNonExistentGlyphs()
QPixmap imageBefore = image;
{
QPainter p(&image);
- p.drawGlyphs(QPointF(50, 50), glyphs);
+ p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -313,7 +313,7 @@ void tst_QGlyphs::drawNonExistentGlyphs()
QCOMPARE(image, imageBefore); // Should be unchanged
}
-void tst_QGlyphs::drawMultiScriptText1()
+void tst_QGlyphRun::drawMultiScriptText1()
{
QString text;
text += QChar(0x03D0); // Greek, beta
@@ -329,7 +329,7 @@ void tst_QGlyphs::drawMultiScriptText1()
QPixmap drawGlyphs(1000, 1000);
drawGlyphs.fill(Qt::white);
- QList<QGlyphs> glyphsList = textLayout.glyphs();
+ QList<QGlyphRun> glyphsList = textLayout.glyphRuns();
QCOMPARE(glyphsList.size(), 1);
{
@@ -339,8 +339,8 @@ void tst_QGlyphs::drawMultiScriptText1()
{
QPainter p(&drawGlyphs);
- foreach (QGlyphs glyphs, glyphsList)
- p.drawGlyphs(QPointF(50, 50), glyphs);
+ foreach (QGlyphRun glyphs, glyphsList)
+ p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -352,7 +352,7 @@ void tst_QGlyphs::drawMultiScriptText1()
}
-void tst_QGlyphs::drawMultiScriptText2()
+void tst_QGlyphRun::drawMultiScriptText2()
{
QString text;
text += QChar(0x0621); // Arabic, Hamza
@@ -369,7 +369,7 @@ void tst_QGlyphs::drawMultiScriptText2()
QPixmap drawGlyphs(1000, 1000);
drawGlyphs.fill(Qt::white);
- QList<QGlyphs> glyphsList = textLayout.glyphs();
+ QList<QGlyphRun> glyphsList = textLayout.glyphRuns();
QCOMPARE(glyphsList.size(), 2);
{
@@ -379,8 +379,8 @@ void tst_QGlyphs::drawMultiScriptText2()
{
QPainter p(&drawGlyphs);
- foreach (QGlyphs glyphs, glyphsList)
- p.drawGlyphs(QPointF(50, 50), glyphs);
+ foreach (QGlyphRun glyphs, glyphsList)
+ p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -391,13 +391,13 @@ void tst_QGlyphs::drawMultiScriptText2()
QCOMPARE(drawGlyphs, textLayoutDraw);
}
-void tst_QGlyphs::detach()
+void tst_QGlyphRun::detach()
{
- QGlyphs glyphs;
+ QGlyphRun glyphs;
glyphs.setGlyphIndexes(QVector<quint32>() << 1 << 2 << 3);
- QGlyphs otherGlyphs;
+ QGlyphRun otherGlyphs;
otherGlyphs = glyphs;
QCOMPARE(otherGlyphs.glyphIndexes(), glyphs.glyphIndexes());
@@ -408,7 +408,7 @@ void tst_QGlyphs::detach()
QCOMPARE(glyphs.glyphIndexes(), QVector<quint32>() << 1 << 2 << 3);
}
-void tst_QGlyphs::drawStruckOutText()
+void tst_QGlyphRun::drawStruckOutText()
{
QPixmap textLayoutDraw(1000, 1000);
QPixmap drawGlyphs(1000, 1000);
@@ -432,13 +432,13 @@ void tst_QGlyphs::drawStruckOutText()
layout.draw(&p, QPointF(50, 50));
}
- QGlyphs glyphs = layout.glyphs().size() > 0
- ? layout.glyphs().at(0)
- : QGlyphs();
+ QGlyphRun glyphs = layout.glyphRuns().size() > 0
+ ? layout.glyphRuns().at(0)
+ : QGlyphRun();
{
QPainter p(&drawGlyphs);
- p.drawGlyphs(QPointF(50, 50), glyphs);
+ p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -449,7 +449,7 @@ void tst_QGlyphs::drawStruckOutText()
QCOMPARE(textLayoutDraw, drawGlyphs);
}
-void tst_QGlyphs::drawOverlinedText()
+void tst_QGlyphRun::drawOverlinedText()
{
QPixmap textLayoutDraw(1000, 1000);
QPixmap drawGlyphs(1000, 1000);
@@ -473,13 +473,13 @@ void tst_QGlyphs::drawOverlinedText()
layout.draw(&p, QPointF(50, 50));
}
- QGlyphs glyphs = layout.glyphs().size() > 0
- ? layout.glyphs().at(0)
- : QGlyphs();
+ QGlyphRun glyphs = layout.glyphRuns().size() > 0
+ ? layout.glyphRuns().at(0)
+ : QGlyphRun();
{
QPainter p(&drawGlyphs);
- p.drawGlyphs(QPointF(50, 50), glyphs);
+ p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -490,7 +490,7 @@ void tst_QGlyphs::drawOverlinedText()
QCOMPARE(textLayoutDraw, drawGlyphs);
}
-void tst_QGlyphs::drawUnderlinedText()
+void tst_QGlyphRun::drawUnderlinedText()
{
QPixmap textLayoutDraw(1000, 1000);
QPixmap drawGlyphs(1000, 1000);
@@ -514,13 +514,13 @@ void tst_QGlyphs::drawUnderlinedText()
layout.draw(&p, QPointF(50, 50));
}
- QGlyphs glyphs = layout.glyphs().size() > 0
- ? layout.glyphs().at(0)
- : QGlyphs();
+ QGlyphRun glyphs = layout.glyphRuns().size() > 0
+ ? layout.glyphRuns().at(0)
+ : QGlyphRun();
{
QPainter p(&drawGlyphs);
- p.drawGlyphs(QPointF(50, 50), glyphs);
+ p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -531,7 +531,7 @@ void tst_QGlyphs::drawUnderlinedText()
QCOMPARE(textLayoutDraw, drawGlyphs);
}
-void tst_QGlyphs::drawRightToLeft()
+void tst_QGlyphRun::drawRightToLeft()
{
QString s;
s.append(QChar(1575));
@@ -557,13 +557,13 @@ void tst_QGlyphs::drawRightToLeft()
layout.draw(&p, QPointF(50, 50));
}
- QGlyphs glyphs = layout.glyphs().size() > 0
- ? layout.glyphs().at(0)
- : QGlyphs();
+ QGlyphRun glyphs = layout.glyphRuns().size() > 0
+ ? layout.glyphRuns().at(0)
+ : QGlyphRun();
{
QPainter p(&drawGlyphs);
- p.drawGlyphs(QPointF(50, 50), glyphs);
+ p.drawGlyphRun(QPointF(50, 50), glyphs);
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -577,6 +577,6 @@ void tst_QGlyphs::drawRightToLeft()
#endif // QT_NO_RAWFONT
-QTEST_MAIN(tst_QGlyphs)
-#include "tst_qglyphs.moc"
+QTEST_MAIN(tst_QGlyphRun)
+#include "tst_qglyphrun.moc"
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index 6c98c67..5987f4a 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -132,33 +132,32 @@ static void setAnchor(QGraphicsAnchorLayout *l,
anchor->setSpacing(spacing);
}
-static bool checkReverseDirection(QGraphicsWidget *w)
+static bool checkReverseDirection(QGraphicsWidget *widget)
{
- QGraphicsLayout *l = w->layout();
- Q_ASSERT(l);
+ QGraphicsLayout *layout = widget->layout();
qreal left, top, right, bottom;
- l->getContentsMargins(&left, &top, &right, &bottom);
- w->setLayoutDirection(Qt::LeftToRight);
+ layout->getContentsMargins(&left, &top, &right, &bottom);
+ widget->setLayoutDirection(Qt::LeftToRight);
QApplication::processEvents();
- const QRectF lg = l->geometry();
+ const QRectF layoutGeometry = layout->geometry();
QMap<QGraphicsLayoutItem *, QRectF> geometries;
- for (int i = 0; i < l->count(); ++i) {
- QGraphicsLayoutItem *w = l->itemAt(i);
- geometries.insert(w, w->geometry());
+ for (int i = 0; i < layout->count(); ++i) {
+ QGraphicsLayoutItem *item = layout->itemAt(i);
+ geometries.insert(item, item->geometry());
}
- w->setLayoutDirection(Qt::RightToLeft);
+ widget->setLayoutDirection(Qt::RightToLeft);
QApplication::processEvents();
- lg.adjusted(+right, +top, -left, -bottom);
- for (int i = 0; i < l->count(); ++i) {
- QGraphicsLayoutItem *w = l->itemAt(i);
- const QRectF rtlGeom = w->geometry();
- const QRectF ltrGeom = geometries.value(w);
- QRectF expectedGeom = ltrGeom;
- expectedGeom.moveRight(lg.right() - (0 + ltrGeom.left()));
- if (expectedGeom != rtlGeom) {
- qDebug() << "layout->geometry():" << lg
- << "expected:" << expectedGeom
- << "actual:" << rtlGeom;
+ layoutGeometry.adjusted(+right, +top, -left, -bottom);
+ for (int i = 0; i < layout->count(); ++i) {
+ QGraphicsLayoutItem *item = layout->itemAt(i);
+ const QRectF rightToLeftGeometry = item->geometry();
+ const QRectF leftToRightGeometry = geometries.value(item);
+ QRectF expectedGeometry = leftToRightGeometry;
+ expectedGeometry.moveRight(layoutGeometry.right() - leftToRightGeometry.left());
+ if (expectedGeometry != rightToLeftGeometry) {
+ qDebug() << "layout->geometry():" << layoutGeometry
+ << "expected:" << expectedGeometry
+ << "actual:" << rightToLeftGeometry;
return false;
}
}
@@ -345,6 +344,7 @@ void tst_QGraphicsAnchorLayout::layoutDirection()
p->show();
view->show();
+ QVERIFY(p->layout());
QCOMPARE(checkReverseDirection(p), true);
if (hasSimplification) {
@@ -445,6 +445,7 @@ void tst_QGraphicsAnchorLayout::diagonal()
QVERIFY(!usedSimplex(l, Qt::Vertical));
}
+ QVERIFY(p.layout());
QCOMPARE(checkReverseDirection(&p), true);
c->setMinimumWidth(300);
@@ -735,6 +736,7 @@ void tst_QGraphicsAnchorLayout::snakeOppositeDirections()
QCOMPARE(c->geometry(), QRectF(90.0, 200.0, 100.0, 100.0));
QCOMPARE(p.size(), layoutMaximumSize);
+ QVERIFY(p.layout());
QCOMPARE(checkReverseDirection(&p), true);
}
diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
index 9e4bb6b..4329f13 100644
--- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
+++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
@@ -2585,15 +2585,11 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution_data()
sizeHints1.insert( Qt::MinimumSize, 30 );
sizeHints1.insert( Qt::PreferredSize, 35 );
sizeHints1.insert( Qt::MaximumSize, 40 );
- Q_ASSERT( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) );
- Q_ASSERT( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) );
SizeHintArray sizeHints2;
sizeHints2.insert( Qt::MinimumSize, 5 );
sizeHints2.insert( Qt::PreferredSize, 35 );
sizeHints2.insert( Qt::MaximumSize, 300 );
- Q_ASSERT( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) );
- Q_ASSERT( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) );
const qreal width1 = 35;
const qreal width2 = 100-10-10-10-width1;
@@ -2605,15 +2601,11 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution_data()
sizeHints1.insert( Qt::MinimumSize, 0 );
sizeHints1.insert( Qt::PreferredSize, 20 );
sizeHints1.insert( Qt::MaximumSize, 100 );
- Q_ASSERT( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) );
- Q_ASSERT( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) );
SizeHintArray sizeHints2;
sizeHints2.insert( Qt::MinimumSize, 0 );
sizeHints2.insert( Qt::PreferredSize, 50 );
sizeHints2.insert( Qt::MaximumSize, 100 );
- Q_ASSERT( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) );
- Q_ASSERT( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) );
const qreal width1 = 20;
const qreal width2 = 100-10-10-10-width1;
@@ -2625,15 +2617,11 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution_data()
sizeHints1.insert( Qt::MinimumSize, 0 );
sizeHints1.insert( Qt::PreferredSize, 40 );
sizeHints1.insert( Qt::MaximumSize, 100 );
- Q_ASSERT( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) );
- Q_ASSERT( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) );
SizeHintArray sizeHints2;
sizeHints2.insert( Qt::MinimumSize, 0 );
sizeHints2.insert( Qt::PreferredSize, 60 );
sizeHints2.insert( Qt::MaximumSize, 100 );
- Q_ASSERT( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) );
- Q_ASSERT( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) );
const qreal width1 = 28; // got from manual calculation
const qreal width2 = 100-10-10-10-width1;
@@ -2645,15 +2633,11 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution_data()
sizeHints1.insert( Qt::MinimumSize, 0 );
sizeHints1.insert( Qt::PreferredSize, 10 );
sizeHints1.insert( Qt::MaximumSize, 100 );
- Q_ASSERT( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) );
- Q_ASSERT( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) );
SizeHintArray sizeHints2;
sizeHints2.insert( Qt::MinimumSize, 0 );
sizeHints2.insert( Qt::PreferredSize, 40 );
sizeHints2.insert( Qt::MaximumSize, 100 );
- Q_ASSERT( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) );
- Q_ASSERT( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) );
const qreal width1 = 22; // got from manual calculation
const qreal width2 = 100-10-10-10-width1;
@@ -2669,6 +2653,12 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution()
QFETCH(qreal, width1);
QFETCH(qreal, width2);
+ // sanity-check the test data - MinimumSize <= PreferredSize <= MaximumSize
+ QVERIFY( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) );
+ QVERIFY( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) );
+ QVERIFY( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) );
+ QVERIFY( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) );
+
// create objects
QGraphicsWidget widget;
TheAnchorLayout *layout = new TheAnchorLayout;
diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index 0b22c52..6b4ad19 100644
--- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -3018,39 +3018,6 @@ static QSizeF wfh(Qt::SizeHint /*which*/, const QSizeF &constraint)
return result;
}
-static qreal growthFactorBelowPreferredSize(qreal desired, qreal sumAvailable, qreal sumDesired)
-{
- Q_ASSERT(sumDesired != 0.0);
- return desired * qPow(sumAvailable / sumDesired, desired / sumDesired);
-}
-
-static void expectedWidth(qreal minSize1, qreal prefSize1,
- qreal minSize2, qreal prefSize2,
- qreal targetSize, qreal *width1, qreal *width2)
-{
- qreal sumAvail,factor1,factor2;
- // stretch behaviour is different below and above preferred size...
- if (targetSize < prefSize1 + prefSize2) {
- sumAvail = targetSize - minSize1 - minSize2;
- const qreal desired1 = prefSize1 - minSize1;
- const qreal desired2 = prefSize2 - minSize2;
- const qreal sumDesired = desired1 + desired2;
- factor1 = growthFactorBelowPreferredSize(desired1, sumAvail, sumDesired);
- factor2 = growthFactorBelowPreferredSize(desired2, sumAvail, sumDesired);
- const qreal sumFactors = factor1 + factor2;
- *width1 = sumAvail*factor1/sumFactors + minSize1;
- *width2 = sumAvail*factor2/sumFactors + minSize2;
- } else {
- sumAvail = targetSize - prefSize1 - prefSize2;
- factor1 = prefSize1;
- factor2 = prefSize2;
- const qreal sumFactors = factor1 + factor2;
- *width1 = sumAvail*factor1/sumFactors + prefSize1;
- *width2 = sumAvail*factor2/sumFactors + prefSize2;
- }
-}
-
-
bool qFuzzyCompare(const QSizeF &a, const QSizeF &b)
{
return qFuzzyCompare(a.width(), b.width()) && qFuzzyCompare(a.height(), b.height());
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 15ed242..9b7b228 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -10732,7 +10732,7 @@ void tst_QGraphicsItem::deviceCoordinateCache_simpleRotations()
QTRY_VERIFY(view.repaints > 0);
QGraphicsItemCache *itemCache = QGraphicsItemPrivate::get(item)->extraItemCache();
- Q_ASSERT(itemCache);
+ QVERIFY(itemCache);
QPixmapCache::Key currentKey = itemCache->deviceData.value(view.viewport()).key;
// Trigger an update and verify that the cache is unchanged.
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index b0e60b0..b8741fe 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -3594,7 +3594,7 @@ void tst_QGraphicsScene::task160653_selectionChanged()
item->flags() | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable);
item->setSelected(true);
}
- Q_ASSERT(scene.items().size() > 1);
+ QVERIFY(scene.items().size() > 1);
QCOMPARE(scene.items().size(), scene.selectedItems().size());
QSignalSpy spy(&scene, SIGNAL(selectionChanged()));
diff --git a/tests/auto/qheaderview/tst_qheaderview.cpp b/tests/auto/qheaderview/tst_qheaderview.cpp
index deab555..c4d5272 100644
--- a/tests/auto/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/qheaderview/tst_qheaderview.cpp
@@ -1106,7 +1106,7 @@ void tst_QHeaderView::moveAndInsertSection()
void tst_QHeaderView::resizeMode()
{
- // Q_ASSERT's when resizeMode is called with an invalid index
+ // resizeMode must not be called with an invalid index
int last = view->count() - 1;
view->setResizeMode(QHeaderView::Interactive);
QCOMPARE(view->resizeMode(last), QHeaderView::Interactive);
diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp
index 676a6b2..6f44033 100644
--- a/tests/auto/qimage/tst_qimage.cpp
+++ b/tests/auto/qimage/tst_qimage.cpp
@@ -151,6 +151,7 @@ private slots:
void rgbSwapped();
void deepCopyWhenPaintingActive();
+ void scaled_QTBUG19157();
};
tst_QImage::tst_QImage()
@@ -2029,5 +2030,12 @@ void tst_QImage::deepCopyWhenPaintingActive()
QVERIFY(copy != image);
}
+void tst_QImage::scaled_QTBUG19157()
+{
+ QImage foo(5000, 1, QImage::Format_RGB32);
+ foo = foo.scaled(1024, 1024, Qt::KeepAspectRatio);
+ QVERIFY(!foo.isNull());
+}
+
QTEST_MAIN(tst_QImage)
#include "tst_qimage.moc"
diff --git a/tests/auto/qinputdialog/tst_qinputdialog.cpp b/tests/auto/qinputdialog/tst_qinputdialog.cpp
index 2587dbc..5c74ab2 100644
--- a/tests/auto/qinputdialog/tst_qinputdialog.cpp
+++ b/tests/auto/qinputdialog/tst_qinputdialog.cpp
@@ -193,12 +193,12 @@ void testGetNumeric(QInputDialog *dialog, SpinBoxType * = 0, ValueType * = 0)
void testGetText(QInputDialog *dialog)
{
QLineEdit *ledit = qFindChild<QLineEdit *>(dialog);
- Q_ASSERT(ledit);
+ QVERIFY(ledit);
QDialogButtonBox *bbox = qFindChild<QDialogButtonBox *>(dialog);
- Q_ASSERT(bbox);
+ QVERIFY(bbox);
QPushButton *okButton = bbox->button(QDialogButtonBox::Ok);
- Q_ASSERT(okButton);
+ QVERIFY(okButton);
QVERIFY(ledit->hasAcceptableInput());
QCOMPARE(ledit->selectedText(), ledit->text());
@@ -211,12 +211,12 @@ void testGetText(QInputDialog *dialog)
void testGetItem(QInputDialog *dialog)
{
QComboBox *cbox = qFindChild<QComboBox *>(dialog);
- Q_ASSERT(cbox);
+ QVERIFY(cbox);
QDialogButtonBox *bbox = qFindChild<QDialogButtonBox *>(dialog);
- Q_ASSERT(bbox);
+ QVERIFY(bbox);
QPushButton *okButton = bbox->button(QDialogButtonBox::Ok);
- Q_ASSERT(okButton);
+ QVERIFY(okButton);
QVERIFY(okButton->isEnabled());
const int origIndex = cbox->currentIndex();
@@ -249,7 +249,7 @@ void tst_QInputDialog::timerEvent(QTimerEvent *event)
{
killTimer(event->timerId());
QInputDialog *dialog = qFindChild<QInputDialog *>(parent);
- Q_ASSERT(dialog);
+ QVERIFY(dialog);
if (testFunc)
testFunc(dialog);
dialog->done(doneCode); // cause static function call to return
@@ -270,7 +270,7 @@ void tst_QInputDialog::getInteger()
{
QFETCH(int, min);
QFETCH(int, max);
- Q_ASSERT(min < max);
+ QVERIFY(min < max);
parent = new QWidget;
doneCode = QDialog::Accepted;
testFunc = &tst_QInputDialog::testFuncGetInteger;
@@ -310,7 +310,7 @@ void tst_QInputDialog::getDouble()
QFETCH(double, min);
QFETCH(double, max);
QFETCH(int, decimals);
- Q_ASSERT(min < max && decimals >= 0 && decimals <= 13);
+ QVERIFY(min < max && decimals >= 0 && decimals <= 13);
parent = new QWidget;
doneCode = QDialog::Accepted;
testFunc = &tst_QInputDialog::testFuncGetDouble;
diff --git a/tests/auto/qitemmodel/modelstotest.cpp b/tests/auto/qitemmodel/modelstotest.cpp
index 59a9d38..772f72b 100644
--- a/tests/auto/qitemmodel/modelstotest.cpp
+++ b/tests/auto/qitemmodel/modelstotest.cpp
@@ -227,7 +227,6 @@ QAbstractItemModel *ModelsToTest::createModel(const QString &modelType)
return widget->model();
}
- Q_ASSERT(false);
return 0;
}
@@ -309,15 +308,23 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model)
*/
}
QModelIndex returnIndex = model->index(0,0);
- Q_ASSERT(returnIndex.isValid());
+ if (!returnIndex.isValid())
+ qFatal("%s: model index to be returned is invalid", Q_FUNC_INFO);
return returnIndex;
}
if (QDirModel *dirModel = qobject_cast<QDirModel *>(model)) {
- // Don't risk somthing bad happening, assert if this fails
- Q_ASSERT(QDir(QDir::currentPath()).mkdir("test"));
- for (int i = 0; i < 26; ++i)
- Q_ASSERT(QDir(QDir::currentPath()).mkdir(QString("test/foo_%1").arg(i)));
+ if (!QDir::current().mkdir("test"))
+ qFatal("%s: cannot create directory %s",
+ Q_FUNC_INFO,
+ qPrintable(QDir::toNativeSeparators(QDir::currentPath()+"/test")));
+ for (int i = 0; i < 26; ++i) {
+ QString subdir = QString("test/foo_%1").arg(i);
+ if (!QDir::current().mkdir(subdir))
+ qFatal("%s: cannot create directory %s",
+ Q_FUNC_INFO,
+ qPrintable(QDir::toNativeSeparators(QDir::currentPath()+"/"+subdir)));
+ }
return dirModel->index(QDir::currentPath()+"/test");
}
@@ -373,7 +380,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model)
return QModelIndex();
}
- Q_ASSERT(false);
+ qFatal("%s: unknown type of model", Q_FUNC_INFO);
return QModelIndex();
}
@@ -387,9 +394,17 @@ void ModelsToTest::cleanupTestArea(QAbstractItemModel *model)
{
if (QDir(QDir::currentPath()+"/test").exists())
{
- for (int i = 0; i < 26; ++i)
- QDir::current().rmdir(QString("test/foo_%1").arg(i));
- Q_ASSERT(QDir::current().rmdir("test"));
+ for (int i = 0; i < 26; ++i) {
+ QString subdir(QString("test/foo_%1").arg(i));
+ if (!QDir::current().rmdir(subdir))
+ qFatal("%s: cannot remove directory %s",
+ Q_FUNC_INFO,
+ qPrintable(QDir::toNativeSeparators(QDir::currentPath()+"/"+subdir)));
+ }
+ if (!QDir::current().rmdir("test"))
+ qFatal("%s: cannot remove directory %s",
+ Q_FUNC_INFO,
+ qPrintable(QDir::toNativeSeparators(QDir::currentPath()+"/test")));
}
} else if (qobject_cast<QSqlQueryModel *>(model)) {
QSqlQuery q("DROP TABLE test");
diff --git a/tests/auto/qitemmodel/tst_qitemmodel.cpp b/tests/auto/qitemmodel/tst_qitemmodel.cpp
index 16f63a7..4bdfadd 100644
--- a/tests/auto/qitemmodel/tst_qitemmodel.cpp
+++ b/tests/auto/qitemmodel/tst_qitemmodel.cpp
@@ -199,6 +199,7 @@ void tst_QItemModel::nonDestructiveBasicTest()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
QCOMPARE(currentModel->buddy(QModelIndex()), QModelIndex());
currentModel->canFetchMore(QModelIndex());
@@ -244,6 +245,7 @@ void tst_QItemModel::rowCount()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
QFETCH(bool, isEmpty);
if (isEmpty) {
@@ -291,6 +293,7 @@ void tst_QItemModel::columnCount()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
QFETCH(bool, isEmpty);
if (isEmpty) {
@@ -325,6 +328,7 @@ void tst_QItemModel::hasIndex()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
// Make sure that invalid values returns an invalid index
QCOMPARE(currentModel->hasIndex(-2, -2), false);
@@ -359,6 +363,7 @@ void tst_QItemModel::index()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
// Make sure that invalid values returns an invalid index
QCOMPARE(currentModel->index(-2, -2), QModelIndex());
@@ -489,6 +494,7 @@ void tst_QItemModel::parent()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
// Make sure the model wont crash and will return an invalid QModelIndex
// when asked for the parent of an invalid index.
@@ -538,6 +544,7 @@ void tst_QItemModel::data()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
// Invalid index should return an invalid qvariant
QVERIFY(!currentModel->data(QModelIndex()).isValid());
@@ -618,6 +625,7 @@ void tst_QItemModel::setData()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
qRegisterMetaType<QModelIndex>("QModelIndex");
QSignalSpy spy(currentModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)));
QCOMPARE(currentModel->setData(QModelIndex(), QVariant()), false);
@@ -660,6 +668,7 @@ void tst_QItemModel::setHeaderData()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
QCOMPARE(currentModel->setHeaderData(-1, Qt::Horizontal, QVariant()), false);
QCOMPARE(currentModel->setHeaderData(-1, Qt::Vertical, QVariant()), false);
@@ -708,6 +717,7 @@ void tst_QItemModel::sort()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
QFETCH(bool, isEmpty);
if (isEmpty)
@@ -819,6 +829,7 @@ void tst_QItemModel::remove()
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
QFETCH(bool, readOnly);
if (readOnly)
@@ -1160,6 +1171,7 @@ void tst_QItemModel::insert()
{
QFETCH(QString, modelType);
currentModel = testModels->createModel(modelType);
+ QVERIFY(currentModel);
QFETCH(bool, readOnly);
if (readOnly)
diff --git a/tests/auto/qitemview/tst_qitemview.cpp b/tests/auto/qitemview/tst_qitemview.cpp
index 8528a77..1f43568 100644
--- a/tests/auto/qitemview/tst_qitemview.cpp
+++ b/tests/auto/qitemview/tst_qitemview.cpp
@@ -148,12 +148,18 @@ public:
CheckerModel() : QStandardItemModel() {};
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole ) const {
- Q_ASSERT(index.isValid());
+ if (!index.isValid()) {
+ qWarning("%s: index is not valid", Q_FUNC_INFO);
+ return QVariant();
+ }
return QStandardItemModel::data(index, role);
};
Qt::ItemFlags flags(const QModelIndex & index) const {
- Q_ASSERT(index.isValid());
+ if (!index.isValid()) {
+ qWarning("%s: index is not valid", Q_FUNC_INFO);
+ return Qt::ItemFlags();
+ }
if (index.row() == 2 || index.row() == rowCount() - 3
|| index.column() == 2 || index.column() == columnCount() - 3) {
Qt::ItemFlags f = QStandardItemModel::flags(index);
@@ -164,14 +170,26 @@ public:
};
QModelIndex parent ( const QModelIndex & child ) const {
- Q_ASSERT(child.isValid());
+ if (!child.isValid()) {
+ qWarning("%s: child index is not valid", Q_FUNC_INFO);
+ return QModelIndex();
+ }
return QStandardItemModel::parent(child);
};
QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const {
- Q_ASSERT(section >= 0);
- if (orientation == Qt::Horizontal) { Q_ASSERT(section <= columnCount());};
- if (orientation == Qt::Vertical) { Q_ASSERT(section <= rowCount());};
+ if (orientation == Qt::Horizontal
+ && (section < 0 || section > columnCount())) {
+ qWarning("%s: invalid section %d, must be in range 0..%d",
+ Q_FUNC_INFO, section, columnCount());
+ return QVariant();
+ }
+ if (orientation == Qt::Vertical
+ && (section < 0 || section > rowCount())) {
+ qWarning("%s: invalid section %d, must be in range 0..%d",
+ Q_FUNC_INFO, section, rowCount());
+ return QVariant();
+ }
return QStandardItemModel::headerData(section, orientation, role);
}
@@ -180,23 +198,46 @@ public:
};
bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ) {
- Q_ASSERT(index.isValid());
+ if (!index.isValid()) {
+ qWarning("%s: index is not valid", Q_FUNC_INFO);
+ return false;
+ }
return QStandardItemModel::setData(index, value, role);
}
void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) {
- Q_ASSERT(column >= 0 && column <= columnCount());
- QStandardItemModel::sort(column, order);
+ if (column < 0 || column > columnCount())
+ qWarning("%s: invalid column %d, must be in range 0..%d",
+ Q_FUNC_INFO, column, columnCount());
+ else
+ QStandardItemModel::sort(column, order);
};
QModelIndexList match ( const QModelIndex & start, int role, const QVariant & value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const {
- Q_ASSERT(hits > 0);
- Q_ASSERT(value.isValid());
+ if (hits <= 0) {
+ qWarning("%s: hits must be greater than zero", Q_FUNC_INFO);
+ return QModelIndexList();
+ }
+ if (!value.isValid()) {
+ qWarning("%s: value is not valid", Q_FUNC_INFO);
+ return QModelIndexList();
+ }
return QAbstractItemModel::match(start, role, value, hits, flags);
};
bool setHeaderData ( int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole ) {
- Q_ASSERT(section >= 0);
+ if (orientation == Qt::Horizontal
+ && (section < 0 || section > columnCount())) {
+ qWarning("%s: invalid section %d, must be in range 0..%d",
+ Q_FUNC_INFO, section, columnCount());
+ return false;
+ }
+ if (orientation == Qt::Vertical
+ && (section < 0 || section > rowCount())) {
+ qWarning("%s: invalid section %d, must be in range 0..%d",
+ Q_FUNC_INFO, section, rowCount());
+ return false;
+ }
return QAbstractItemModel::setHeaderData(section, orientation, value, role);
};
};
@@ -297,9 +338,11 @@ void tst_QItemView::nonDestructiveBasicTest()
#endif
QFETCH(QString, viewType);
- view = testViews->createView(viewType);
QFETCH(int, vscroll);
QFETCH(int, hscroll);
+
+ view = testViews->createView(viewType);
+ QVERIFY(view);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
@@ -454,9 +497,11 @@ void tst_QItemView::spider()
QSKIP("This test takes too long to execute on IRIX", SkipAll);
#endif
QFETCH(QString, viewType);
- view = testViews->createView(viewType);
QFETCH(int, vscroll);
QFETCH(int, hscroll);
+
+ view = testViews->createView(viewType);
+ QVERIFY(view);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
view->setModel(treeModel);
@@ -489,9 +534,11 @@ void tst_QItemView::resize()
// This test needs to be re-thought out, it takes too long and
// doesn't really catch theproblem.
QFETCH(QString, viewType);
- view = testViews->createView(viewType);
QFETCH(int, vscroll);
QFETCH(int, hscroll);
+
+ view = testViews->createView(viewType);
+ QVERIFY(view);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
view->setModel(treeModel);
@@ -517,9 +564,11 @@ void tst_QItemView::visualRect()
QSKIP("This test takes too long to execute on IRIX", SkipAll);
#endif
QFETCH(QString, viewType);
- view = testViews->createView(viewType);
QFETCH(int, vscroll);
QFETCH(int, hscroll);
+
+ view = testViews->createView(viewType);
+ QVERIFY(view);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
QCOMPARE(view->visualRect(QModelIndex()), QRect());
@@ -651,9 +700,11 @@ void tst_QItemView::indexAt()
QSKIP("This test takes too long to execute on IRIX", SkipAll);
#endif
QFETCH(QString, viewType);
- view = testViews->createView(viewType);
QFETCH(int, vscroll);
QFETCH(int, hscroll);
+
+ view = testViews->createView(viewType);
+ QVERIFY(view);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
view->show();
@@ -685,9 +736,11 @@ void tst_QItemView::scrollTo()
QSKIP("This test takes too long to execute on IRIX", SkipAll);
#endif
QFETCH(QString, viewType);
- view = testViews->createView(viewType);
QFETCH(int, vscroll);
QFETCH(int, hscroll);
+
+ view = testViews->createView(viewType);
+ QVERIFY(view);
view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll);
view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll);
view->setModel(treeModel);
@@ -735,6 +788,7 @@ void tst_QItemView::moveCursor()
#endif
QFETCH(QString, viewType);
view = testViews->createView(viewType);
+ QVERIFY(view);
if (view->objectName() == "QHeaderView")
return;
diff --git a/tests/auto/qitemview/viewstotest.cpp b/tests/auto/qitemview/viewstotest.cpp
index 9a29e50..690e1c2 100644
--- a/tests/auto/qitemview/viewstotest.cpp
+++ b/tests/auto/qitemview/viewstotest.cpp
@@ -141,7 +141,6 @@ QAbstractItemView *ViewsToTest::createView(const QString &viewType)
view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
view->setSelectionBehavior(QAbstractItemView::SelectItems);
}
- Q_ASSERT(view);
return view;
}
diff --git a/tests/auto/qlibrary/tst_qlibrary.cpp b/tests/auto/qlibrary/tst_qlibrary.cpp
index e89cdd7..0c31fdd 100644
--- a/tests/auto/qlibrary/tst_qlibrary.cpp
+++ b/tests/auto/qlibrary/tst_qlibrary.cpp
@@ -468,7 +468,7 @@ void tst_QLibrary::errorString()
}
break;}
default:
- Q_ASSERT(0);
+ QFAIL(qPrintable(QString("Unknown operation: %1").arg(operation)));
break;
}
QRegExp re(errorString);
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index 39dc345..f0f1685 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -3815,7 +3815,7 @@ void tst_QLineEdit::bidiVisualMovement()
QLineEdit le;
le.setText(logical);
- le.setCursorMoveStyle(QTextCursor::Visual);
+ le.setCursorMoveStyle(Qt::VisualMoveStyle);
le.setCursorPosition(0);
bool moved;
@@ -3863,7 +3863,7 @@ void tst_QLineEdit::bidiLogicalMovement()
QLineEdit le;
le.setText(logical);
- le.setCursorMoveStyle(QTextCursor::Logical);
+ le.setCursorMoveStyle(Qt::LogicalMoveStyle);
le.setCursorPosition(0);
bool moved;
diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp
index f8f7280..b9e5fd9 100644
--- a/tests/auto/qlocale/tst_qlocale.cpp
+++ b/tests/auto/qlocale/tst_qlocale.cpp
@@ -326,7 +326,7 @@ void tst_QLocale::ctor()
TEST_CTOR("en-GB", English, UnitedKingdom)
TEST_CTOR("en-GB@bla", English, UnitedKingdom)
- Q_ASSERT(QLocale::Norwegian == QLocale::NorwegianBokmal);
+ QVERIFY(QLocale::Norwegian == QLocale::NorwegianBokmal);
TEST_CTOR("no", Norwegian, Norway)
TEST_CTOR("nb", Norwegian, Norway)
TEST_CTOR("nn", NorwegianNynorsk, Norway)
@@ -431,7 +431,7 @@ void tst_QLocale::emptyCtor()
TEST_CTOR("en_GB@bla", "en_GB")
TEST_CTOR("de", "de_DE")
- Q_ASSERT(QLocale::Norwegian == QLocale::NorwegianBokmal);
+ QVERIFY(QLocale::Norwegian == QLocale::NorwegianBokmal);
TEST_CTOR("no", "nb_NO")
TEST_CTOR("nb", "nb_NO")
TEST_CTOR("nn", "nn_NO")
diff --git a/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/main.cpp b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/main.cpp
new file mode 100644
index 0000000..a023aa6
--- /dev/null
+++ b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/main.cpp
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+int main(int,char**)
+{
+}
diff --git a/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/simple.pro b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/simple.pro
new file mode 100644
index 0000000..2db08a2
--- /dev/null
+++ b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/simple.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+SOURCES = main.cpp
+
+extratarget.commands = @echo extra target worked OK
+QMAKE_EXTRA_TARGETS += extratarget
diff --git a/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/subdir.pro b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/subdir.pro
new file mode 100644
index 0000000..be0d80a
--- /dev/null
+++ b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/subdir.pro
@@ -0,0 +1,7 @@
+TEMPLATE = subdirs
+SUBDIRS = simple
+
+extratarget.CONFIG = recursive
+extratarget.recurse = $$SUBDIRS
+extratarget.recurse_target = extratarget
+QMAKE_EXTRA_TARGETS += extratarget
diff --git a/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/subdir_via_pro_file_extra_target.pro b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/subdir_via_pro_file_extra_target.pro
new file mode 100644
index 0000000..7c07859
--- /dev/null
+++ b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/subdir_via_pro_file_extra_target.pro
@@ -0,0 +1,7 @@
+TEMPLATE = subdirs
+SUBDIRS = subdir.pro
+
+extratarget.CONFIG = recursive
+extratarget.recurse = $$SUBDIRS
+extratarget.recurse_target = extratarget
+QMAKE_EXTRA_TARGETS += extratarget
diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp
index fdeeef7..2775b53 100644
--- a/tests/auto/qmake/tst_qmake.cpp
+++ b/tests/auto/qmake/tst_qmake.cpp
@@ -69,6 +69,7 @@ private slots:
void simple_lib();
void simple_dll();
void subdirs();
+ void subdir_via_pro_file_extra_target();
void functions();
void operators();
void variables();
@@ -234,6 +235,19 @@ void tst_qmake::subdirs()
QVERIFY( test_compiler.removeMakefile( workDir ) );
}
+void tst_qmake::subdir_via_pro_file_extra_target()
+{
+ QString workDir = base_path + "/testdata/subdir_via_pro_file_extra_target";
+
+ QDir D;
+ D.remove( workDir + "/Makefile");
+ D.remove( workDir + "/Makefile.subdir");
+ D.remove( workDir + "/simple/Makefile");
+ D.remove( workDir + "/simple/Makefile.subdir");
+ QVERIFY( test_compiler.qmake( workDir, "subdir_via_pro_file_extra_target" ));
+ QVERIFY( test_compiler.make( workDir, "extratarget" ));
+}
+
void tst_qmake::functions()
{
QString workDir = base_path + "/testdata/functions";
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index 26b31ee..d99df95 100644
--- a/tests/auto/qmenu/tst_qmenu.cpp
+++ b/tests/auto/qmenu/tst_qmenu.cpp
@@ -789,7 +789,7 @@ void tst_QMenu::task250673_activeMultiColumnSubMenuPosition()
while (main.columnCount() < 2) {
main.addAction(QString("Item %1").arg(i));
++i;
- Q_ASSERT(i<1000);
+ QVERIFY(i<1000);
}
main.setActiveAction(menuAction);
sub.setActiveAction(subAction);
diff --git a/tests/auto/qmessagebox/tst_qmessagebox.cpp b/tests/auto/qmessagebox/tst_qmessagebox.cpp
index fadb24c..ed085ce 100644
--- a/tests/auto/qmessagebox/tst_qmessagebox.cpp
+++ b/tests/auto/qmessagebox/tst_qmessagebox.cpp
@@ -609,48 +609,43 @@ void tst_QMessageBox::testSymbols()
button = QMessageBox::FlagMask;
mb1.setText("Foo");
- QString text = mb1.text();
- Q_ASSERT(text == "Foo");
+ QCOMPARE(mb1.text(), "Foo");
icon = mb1.icon();
- Q_ASSERT(icon == QMessageBox::NoIcon);
+ QVERIFY(icon == QMessageBox::NoIcon);
mb1.setIcon(QMessageBox::Question);
- Q_ASSERT(mb1.icon() == QMessageBox::Question);
+ QVERIFY(mb1.icon() == QMessageBox::Question);
QPixmap iconPixmap = mb1.iconPixmap();
mb1.setIconPixmap(iconPixmap);
- Q_ASSERT(mb1.icon() == QMessageBox::NoIcon);
+ QVERIFY(mb1.icon() == QMessageBox::NoIcon);
- QString bt0 = mb1.buttonText(QMessageBox::Ok);
- QString bt1 = mb1.buttonText(QMessageBox::Cancel);
- QString bt2 = mb1.buttonText(QMessageBox::Ok | QMessageBox::Default);
-
- Q_ASSERT(bt0 == "OK");
- Q_ASSERT(bt1.isEmpty());
- Q_ASSERT(bt2.isEmpty());
+ QCOMPARE(mb1.buttonText(QMessageBox::Ok), "OK");
+ QCOMPARE(mb1.buttonText(QMessageBox::Cancel), QString());
+ QCOMPARE(mb1.buttonText(QMessageBox::Ok | QMessageBox::Default), QString());
mb2.setButtonText(QMessageBox::Cancel, "Foo");
mb2.setButtonText(QMessageBox::Ok, "Bar");
mb2.setButtonText(QMessageBox::Ok | QMessageBox::Default, "Baz");
- Q_ASSERT(mb2.buttonText(QMessageBox::Cancel).isEmpty());
- Q_ASSERT(mb2.buttonText(QMessageBox::Ok) == "Bar");
+ QCOMPARE(mb2.buttonText(QMessageBox::Cancel), QString());
+ QCOMPARE(mb2.buttonText(QMessageBox::Ok), "Bar");
- Q_ASSERT(mb3b.buttonText(QMessageBox::Yes).endsWith("Yes"));
- Q_ASSERT(mb3b.buttonText(QMessageBox::YesAll).isEmpty());
- Q_ASSERT(mb3b.buttonText(QMessageBox::Ok).isEmpty());
+ QVERIFY(mb3b.buttonText(QMessageBox::Yes).endsWith("Yes"));
+ QCOMPARE(mb3b.buttonText(QMessageBox::YesAll), QString());
+ QCOMPARE(mb3b.buttonText(QMessageBox::Ok), QString());
mb3b.setButtonText(QMessageBox::Yes, "Blah");
mb3b.setButtonText(QMessageBox::YesAll, "Zoo");
mb3b.setButtonText(QMessageBox::Ok, "Zoo");
- Q_ASSERT(mb3b.buttonText(QMessageBox::Yes) == "Blah");
- Q_ASSERT(mb3b.buttonText(QMessageBox::YesAll).isEmpty());
- Q_ASSERT(mb3b.buttonText(QMessageBox::Ok).isEmpty());
+ QCOMPARE(mb3b.buttonText(QMessageBox::Yes), "Blah");
+ QCOMPARE(mb3b.buttonText(QMessageBox::YesAll), QString());
+ QCOMPARE(mb3b.buttonText(QMessageBox::Ok), QString());
- Q_ASSERT(mb1.textFormat() == Qt::AutoText);
+ QCOMPARE(mb1.textFormat(), Qt::AutoText);
mb1.setTextFormat(Qt::PlainText);
- Q_ASSERT(mb1.textFormat() == Qt::PlainText);
+ QCOMPARE(mb1.textFormat(), Qt::PlainText);
CONVENIENCE_FUNC_SYMS(information);
CONVENIENCE_FUNC_SYMS_EXTRA(information);
@@ -660,7 +655,7 @@ void tst_QMessageBox::testSymbols()
CONVENIENCE_FUNC_SYMS(critical);
QSize sizeHint = mb1.sizeHint();
- Q_ASSERT(sizeHint.width() > 20 && sizeHint.height() > 20);
+ QVERIFY(sizeHint.width() > 20 && sizeHint.height() > 20);
#ifdef QT3_SUPPORT
//test QT3_SUPPORT stuff
@@ -672,8 +667,8 @@ void tst_QMessageBox::testSymbols()
QPixmap pm = QMessageBox::standardIcon(QMessageBox::Question, Qt::GUIStyle(1));
QPixmap pm2 = QMessageBox::standardIcon(QMessageBox::Question);
- Q_ASSERT(pm.toImage() == iconPixmap.toImage());
- Q_ASSERT(pm2.toImage() == iconPixmap.toImage());
+ QVERIFY(pm.toImage() == iconPixmap.toImage());
+ QVERIFY(pm2.toImage() == iconPixmap.toImage());
int ret1 = QMessageBox::message("title", "text");
int ret2 = QMessageBox::message("title", "text", "OK");
@@ -692,10 +687,10 @@ void tst_QMessageBox::testSymbols()
Q_UNUSED(ret5);
QPixmap pm3 = QMessageBox::standardIcon(QMessageBox::NoIcon);
- Q_ASSERT(pm3.isNull());
+ QVERIFY(pm3.isNull());
pm3 = QMessageBox::standardIcon(QMessageBox::Information);
- Q_ASSERT(!pm3.isNull());
+ QVERIFY(!pm3.isNull());
#endif //QT3_SUPPORT
QMessageBox::about(&mb1, "title", "text");
diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp
index dc37499..a813a91 100644
--- a/tests/auto/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp
@@ -244,7 +244,12 @@ public:
QObject *child;
public slots:
- void on_child1_destroyed(QObject *obj = 0) { ++invokeCount1; Q_ASSERT(obj && obj == child); }
+ void on_child1_destroyed(QObject *obj = 0)
+ {
+ ++invokeCount1;
+ if (!obj || obj != child)
+ qWarning() << "on_child1_destroyed invoked with wrong child object";
+ }
void on_child2_destroyed() { ++invokeCount2; }
};
@@ -268,7 +273,12 @@ public:
}
private slots:
- void on_child1_destroyed(QObject *obj) { ++invokeCount1; Q_ASSERT(obj && obj == child); }
+ void on_child1_destroyed(QObject *obj)
+ {
+ ++invokeCount1;
+ if (!obj || obj != child)
+ qWarning() << "on_child1_destroyed invoked with wrong child object";
+ }
void on_child1_destroyed() { ++invokeCount2; }
};
diff --git a/tests/auto/qmetatype/tst_qmetatype.cpp b/tests/auto/qmetatype/tst_qmetatype.cpp
index cb243f7..897664e 100644
--- a/tests/auto/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/qmetatype/tst_qmetatype.cpp
@@ -96,10 +96,18 @@ struct Bar
Bar()
{
// check re-entrancy
- Q_ASSERT(QMetaType::isRegistered(qRegisterMetaType<Foo>("Foo")));
+ if (!QMetaType::isRegistered(qRegisterMetaType<Foo>("Foo"))) {
+ qWarning("%s: re-entrancy test failed", Q_FUNC_INFO);
+ ++failureCount;
+ }
}
+
+public:
+ static int failureCount;
};
+int Bar::failureCount = 0;
+
class MetaTypeTorturer: public QThread
{
Q_OBJECT
@@ -113,17 +121,35 @@ protected:
#ifdef Q_OS_LINUX
pthread_yield();
#endif
- Q_ASSERT(QMetaType::isRegistered(tp));
- Q_ASSERT(QMetaType::type(nm) == tp);
- Q_ASSERT(QMetaType::typeName(tp) == name);
+ if (!QMetaType::isRegistered(tp)) {
+ ++failureCount;
+ qWarning() << name << "is not a registered metatype";
+ }
+ if (QMetaType::type(nm) != tp) {
+ ++failureCount;
+ qWarning() << "Wrong metatype returned for" << name;
+ }
+ if (QMetaType::typeName(tp) != name) {
+ ++failureCount;
+ qWarning() << "Wrong typeName returned for" << tp;
+ }
void *buf = QMetaType::construct(tp, 0);
void *buf2 = QMetaType::construct(tp, buf);
- Q_ASSERT(buf);
- Q_ASSERT(buf2);
+ if (!buf) {
+ ++failureCount;
+ qWarning() << "Null buffer returned by QMetaType::construct(tp, 0)";
+ }
+ if (!buf2) {
+ ++failureCount;
+ qWarning() << "Null buffer returned by QMetaType::construct(tp, buf)";
+ }
QMetaType::destroy(tp, buf);
QMetaType::destroy(tp, buf2);
}
}
+public:
+ MetaTypeTorturer() : failureCount(0) { }
+ int failureCount;
};
void tst_QMetaType::threadSafety()
@@ -139,6 +165,11 @@ void tst_QMetaType::threadSafety()
QVERIFY(t1.wait());
QVERIFY(t2.wait());
QVERIFY(t3.wait());
+
+ QCOMPARE(t1.failureCount, 0);
+ QCOMPARE(t2.failureCount, 0);
+ QCOMPARE(t3.failureCount, 0);
+ QCOMPARE(Bar::failureCount, 0);
}
namespace TestSpace
diff --git a/tests/auto/qmutex/tst_qmutex.cpp b/tests/auto/qmutex/tst_qmutex.cpp
index 775826d..0a9fc0a 100644
--- a/tests/auto/qmutex/tst_qmutex.cpp
+++ b/tests/auto/qmutex/tst_qmutex.cpp
@@ -462,6 +462,7 @@ public:
static QBasicAtomicInt lockCount;
static QBasicAtomicInt sentinel;
static QMutex mutex;
+ static int errorCount;
void start()
{
t.start();
@@ -471,13 +472,13 @@ public:
{
while (t.elapsed() < one_minute) {
mutex.lock();
- Q_ASSERT(!sentinel.ref());
- Q_ASSERT(sentinel.deref());
+ if (sentinel.ref()) ++errorCount;
+ if (!sentinel.deref()) ++errorCount;
lockCount.ref();
mutex.unlock();
if (mutex.tryLock()) {
- Q_ASSERT(!sentinel.ref());
- Q_ASSERT(sentinel.deref());
+ if (sentinel.ref()) ++errorCount;
+ if (!sentinel.deref()) ++errorCount;
lockCount.ref();
mutex.unlock();
}
@@ -487,6 +488,7 @@ public:
QMutex StressTestThread::mutex;
QBasicAtomicInt StressTestThread::lockCount = Q_BASIC_ATOMIC_INITIALIZER(0);
QBasicAtomicInt StressTestThread::sentinel = Q_BASIC_ATOMIC_INITIALIZER(-1);
+int StressTestThread::errorCount = 0;
void tst_QMutex::stressTest()
{
@@ -496,6 +498,7 @@ void tst_QMutex::stressTest()
QVERIFY(threads[0].wait(one_minute + 10000));
for (int i = 1; i < threadCount; ++i)
QVERIFY(threads[i].wait(10000));
+ QCOMPARE(StressTestThread::errorCount, 0);
qDebug("locked %d times", int(StressTestThread::lockCount));
}
@@ -534,7 +537,12 @@ void tst_QMutex::tryLockRace()
TryLockRaceThread::mutex.unlock();
}
+// Variable that will be protected by the mutex. Volatile so that the
+// the optimiser doesn't mess with it based on the increment-then-decrement
+// usage pattern.
static volatile int qtbug16115_trylock_counter;
+// Counter for how many times the protected variable has an incorrect value.
+static int qtbug16115_failure_count = 0;
void tst_QMutex::qtbug16115_trylock()
{
@@ -545,8 +553,10 @@ void tst_QMutex::qtbug16115_trylock()
void run() {
for (int i = 0; i < 1000000; ++i) {
if (mut.tryLock(0)) {
- Q_ASSERT((++qtbug16115_trylock_counter) == 1);
- Q_ASSERT((--qtbug16115_trylock_counter) == 0);
+ if ((++qtbug16115_trylock_counter) != 1)
+ ++qtbug16115_failure_count;
+ if ((--qtbug16115_trylock_counter) != 0)
+ ++qtbug16115_failure_count;
mut.unlock();
}
}
@@ -562,13 +572,16 @@ void tst_QMutex::qtbug16115_trylock()
for (int i = 0; i < 1000000; ++i) {
mut.lock();
- Q_ASSERT((++qtbug16115_trylock_counter) == 1);
- Q_ASSERT((--qtbug16115_trylock_counter) == 0);
+ if ((++qtbug16115_trylock_counter) != 1)
+ ++qtbug16115_failure_count;
+ if ((--qtbug16115_trylock_counter) != 0)
+ ++qtbug16115_failure_count;
mut.unlock();
}
t1.wait();
t2.wait();
t3.wait();
+ QCOMPARE(qtbug16115_failure_count, 0);
}
QTEST_MAIN(tst_QMutex)
diff --git a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
index 57bf583..d29ef77 100644
--- a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
+++ b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
@@ -62,6 +62,7 @@ public slots:
void cleanup();
private slots:
+ void usedInThread(); // this test must be first, or it will falsely pass
void allConfigurations();
void defaultConfiguration();
void configurationFromIdentifier();
@@ -329,6 +330,49 @@ void tst_QNetworkConfigurationManager::configurationFromIdentifier()
QVERIFY(!invalid.isValid());
}
+class QNCMTestThread : public QThread
+{
+protected:
+ virtual void run()
+ {
+ QNetworkConfigurationManager manager;
+ preScanConfigs = manager.allConfigurations();
+ QSignalSpy spy(&manager, SIGNAL(updateCompleted()));
+ manager.updateConfigurations(); //initiate scans
+ QTRY_VERIFY(spy.count() == 1); //wait for scan to complete
+ configs = manager.allConfigurations();
+ }
+public:
+ QList<QNetworkConfiguration> configs;
+ QList<QNetworkConfiguration> preScanConfigs;
+};
+
+// regression test for QTBUG-18795
+void tst_QNetworkConfigurationManager::usedInThread()
+{
+#if defined Q_OS_MAC && !defined (QT_NO_COREWLAN)
+ QSKIP("QTBUG-19070 Mac CoreWlan plugin is broken", SkipAll);
+#else
+ QNCMTestThread thread;
+ connect(&thread, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ thread.start();
+ QTestEventLoop::instance().enterLoop(100); //QTRY_VERIFY could take ~90 seconds to time out in the thread
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ qDebug() << "prescan:" << thread.preScanConfigs.count();
+ qDebug() << "postscan:" << thread.configs.count();
+
+ QNetworkConfigurationManager manager;
+ QList<QNetworkConfiguration> preScanConfigs = manager.allConfigurations();
+ QSignalSpy spy(&manager, SIGNAL(updateCompleted()));
+ manager.updateConfigurations(); //initiate scans
+ QTRY_VERIFY(spy.count() == 1); //wait for scan to complete
+ QList<QNetworkConfiguration> configs = manager.allConfigurations();
+ QCOMPARE(thread.configs, configs);
+ //Don't compare pre scan configs, because these may be cached and therefore give different results
+ //which makes the test unstable. The post scan results should have all configurations every time
+ //QCOMPARE(thread.preScanConfigs, preScanConfigs);
+#endif
+}
QTEST_MAIN(tst_QNetworkConfigurationManager)
#include "tst_qnetworkconfigurationmanager.moc"
diff --git a/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
index bcd63ff..e03c8e9 100644
--- a/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
+++ b/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
@@ -46,6 +46,7 @@
#include <qcoreapplication.h>
#include <qdebug.h>
#include <qnetworkproxy.h>
+#include <QThread>
#include <QNetworkConfiguration>
#include <QNetworkConfigurationManager>
#include <QNetworkSession>
@@ -77,6 +78,7 @@ public:
};
private slots:
+ void systemProxyForQueryCalledFromThread();
void systemProxyForQuery() const;
#ifndef QT_NO_BEARERMANAGEMENT
void fromConfigurations();
@@ -136,6 +138,32 @@ void tst_QNetworkProxyFactory::systemProxyForQuery() const
QFAIL("One or more system proxy lookup failures occurred.");
}
+class QSPFQThread : public QThread
+{
+protected:
+ virtual void run()
+ {
+ proxies = QNetworkProxyFactory::systemProxyForQuery(query);
+ }
+public:
+ QNetworkProxyQuery query;
+ QList<QNetworkProxy> proxies;
+};
+
+//regression test for QTBUG-18799
+void tst_QNetworkProxyFactory::systemProxyForQueryCalledFromThread()
+{
+ QUrl url(QLatin1String("http://qt.nokia.com"));
+ QNetworkProxyQuery query(url);
+ QSPFQThread thread;
+ thread.query = query;
+ connect(&thread, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ thread.start();
+ QTestEventLoop::instance().enterLoop(5);
+ QVERIFY(thread.isFinished());
+ QCOMPARE(thread.proxies, QNetworkProxyFactory::systemProxyForQuery(query));
+}
+
#ifndef QT_NO_BEARERMANAGEMENT
//Purpose of this test is just to check systemProxyForQuery doesn't hang or crash
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 66228ee..c70075f 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -622,9 +622,14 @@ public:
}
QIODevice *prepare(const QNetworkCacheMetaData &)
- { Q_ASSERT(0 && "Should not have tried to add to the cache"); return 0; }
+ {
+ qFatal("%s: Should not have tried to add to the cache", Q_FUNC_INFO);
+ return 0;
+ }
void insert(QIODevice *)
- { Q_ASSERT(0 && "Should not have tried to add to the cache"); }
+ {
+ qFatal("%s: Should not have tried to add to the cache", Q_FUNC_INFO);
+ }
void clear() { cache.clear(); }
};
@@ -774,7 +779,9 @@ public:
QTcpSocket* waitForNextConnectionSocket() {
waitForNewConnection(-1);
if (doSsl) {
- Q_ASSERT(sslSocket);
+ if (!sslSocket)
+ qFatal("%s: sslSocket should not be null after calling waitForNewConnection()",
+ Q_FUNC_INFO);
return sslSocket;
} else {
//qDebug() << "returning nextPendingConnection";
@@ -946,7 +953,8 @@ protected:
while (dataIndex < wantedSize) {
const int remainingBytes = wantedSize - measuredSentBytes;
const int bytesToWrite = qMin(remainingBytes, static_cast<int>(BlockSize));
- Q_ASSERT(bytesToWrite);
+ if (bytesToWrite <= 0)
+ qFatal("%s: attempt to write %d bytes", Q_FUNC_INFO, bytesToWrite);
measuredSentBytes += writeNextData(client, bytesToWrite);
while (client->bytesToWrite() > 0) {
@@ -1005,7 +1013,8 @@ public:
// Wait for data to be readyRead
bool ok = connect(&senderObj, SIGNAL(dataReady()), this, SLOT(slotDataReady()));
- Q_ASSERT(ok);
+ if (!ok)
+ qFatal("%s: Cannot connect dataReady signal", Q_FUNC_INFO);
}
void wrapUp()
@@ -1028,9 +1037,9 @@ protected:
void timerEvent(QTimerEvent *)
{
//qDebug() << "RateControlledReader: timerEvent bytesAvailable=" << device->bytesAvailable();
- if (readBufferSize > 0) {
- // This asserts passes all the time, except in the final flush.
- //Q_ASSERT(device->bytesAvailable() <= readBufferSize);
+ if (readBufferSize > 0 && device->bytesAvailable() > readBufferSize) {
+ // This passes all the time, except in the final flush.
+ //qFatal("%s: Too many bytes available", Q_FUNC_INFO);
}
qint64 bytesRead = 0;
@@ -1189,7 +1198,7 @@ QString tst_QNetworkReply::runSimpleRequest(QNetworkAccessManager::Operation op,
break;
default:
- Q_ASSERT_X(false, "tst_QNetworkReply", "Invalid/unknown operation requested");
+ qFatal("%s: Invalid/unknown operation requested", Q_FUNC_INFO);
}
reply->setParent(this);
diff --git a/tests/auto/qobject/signalbug.cpp b/tests/auto/qobject/signalbug.cpp
index c1f7f51..f81de47 100644
--- a/tests/auto/qobject/signalbug.cpp
+++ b/tests/auto/qobject/signalbug.cpp
@@ -69,7 +69,8 @@ void Receiver::received ()
::Step++;
const int stepCopy = ::Step;
TRACE (stepCopy, "Receiver::received()");
- Q_ASSERT (::Step == 2 || ::Step == 4);
+ if (::Step != 2 && ::Step != 4)
+ qFatal("%s: Incorrect Step: %d (should be 2 or 4)", Q_FUNC_INFO, ::Step);
if (::Step == 2)
s->fire ();
@@ -91,7 +92,8 @@ void Disconnector::received ()
::Step++;
const int stepCopy = ::Step;
TRACE (stepCopy, "Disconnector::received()");
- Q_ASSERT (::Step == 5 || ::Step == 6);
+ if (::Step != 5 && ::Step != 6)
+ qFatal("%s: Incorrect Step: %d (should be 5 or 6)", Q_FUNC_INFO, ::Step);
fprintf (stderr, "Disconnector<%s>::received() sender=%s\n",
(const char *) objectName ().toAscii (), sender ()->metaObject()->className());
@@ -124,7 +126,8 @@ void Sender::fire ()
::Step++;
const int stepCopy = ::Step;
TRACE (stepCopy, "Sender::fire()");
- Q_ASSERT (::Step == 1 || ::Step == 3);
+ if (::Step != 1 && ::Step != 3)
+ qFatal("%s: Incorrect Step: %d (should be 1 or 3)", Q_FUNC_INFO, ::Step);
emit fired ();
TRACE (stepCopy, "ends Sender::fire()");
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp
index 2837cd4..c7db032 100644
--- a/tests/auto/qobject/tst_qobject.cpp
+++ b/tests/auto/qobject/tst_qobject.cpp
@@ -403,6 +403,8 @@ public:
}
void reset() {
+ called_slot10 = 0;
+ called_slot9 = 0;
called_slot8 = 0;
called_slot7 = 0;
called_slot6 = 0;
@@ -421,6 +423,8 @@ public:
int called_slot6;
int called_slot7;
int called_slot8;
+ int called_slot9;
+ int called_slot10;
bool called(int slot) {
switch (slot) {
@@ -432,6 +436,8 @@ public:
case 6: return called_slot6;
case 7: return called_slot7;
case 8: return called_slot8;
+ case 9: return called_slot9;
+ case 10: return called_slot10;
default: return false;
}
}
@@ -449,8 +455,8 @@ public slots:
void slotLoopBack() { ++called_slot8; }
protected slots:
- void o() { Q_ASSERT(0); }
- void on() { Q_ASSERT(0); }
+ void o() { ++called_slot9; }
+ void on() { ++called_slot10; }
signals:
void on_Sender_signalLoopBack();
@@ -473,6 +479,8 @@ void tst_QObject::connectByName()
QCOMPARE(receiver.called(6), false);
QCOMPARE(receiver.called(7), false);
QCOMPARE(receiver.called(8), false);
+ QCOMPARE(receiver.called(9), false);
+ QCOMPARE(receiver.called(10), false);
receiver.reset();
sender.emitSignalWithParams(0);
@@ -484,6 +492,8 @@ void tst_QObject::connectByName()
QCOMPARE(receiver.called(6), false);
QCOMPARE(receiver.called(7), false);
QCOMPARE(receiver.called(8), false);
+ QCOMPARE(receiver.called(9), false);
+ QCOMPARE(receiver.called(10), false);
receiver.reset();
sender.emitSignalWithParams(0, "string");
@@ -495,6 +505,8 @@ void tst_QObject::connectByName()
QCOMPARE(receiver.called(6), false);
QCOMPARE(receiver.called(7), false);
QCOMPARE(receiver.called(8), false);
+ QCOMPARE(receiver.called(9), false);
+ QCOMPARE(receiver.called(10), false);
receiver.reset();
sender.emitSignalManyParams(1, 2, 3, "string", true);
@@ -506,6 +518,8 @@ void tst_QObject::connectByName()
QCOMPARE(receiver.called(6), false);
QCOMPARE(receiver.called(7), false);
QCOMPARE(receiver.called(8), false);
+ QCOMPARE(receiver.called(9), false);
+ QCOMPARE(receiver.called(10), false);
receiver.reset();
sender.emitSignalManyParams2(1, 2, 3, "string", true);
@@ -517,6 +531,8 @@ void tst_QObject::connectByName()
QCOMPARE(receiver.called(6), false);
QCOMPARE(receiver.called(7), true);
QCOMPARE(receiver.called(8), false);
+ QCOMPARE(receiver.called(9), false);
+ QCOMPARE(receiver.called(10), false);
receiver.reset();
sender.emitSignalLoopBack();
@@ -528,6 +544,8 @@ void tst_QObject::connectByName()
QCOMPARE(receiver.called(6), false);
QCOMPARE(receiver.called(7), false);
QCOMPARE(receiver.called(8), true);
+ QCOMPARE(receiver.called(9), false);
+ QCOMPARE(receiver.called(10), false);
receiver.reset();
}
@@ -1312,14 +1330,16 @@ public:
void customEvent(QEvent *)
{
- Q_ASSERT(customEventThread == 0);
+ if (customEventThread)
+ qFatal("%s: customEventThread should be null", Q_FUNC_INFO);
customEventThread = QThread::currentThread();
emit theSignal();
}
void timerEvent(QTimerEvent *)
{
- Q_ASSERT(timerEventThread == 0);
+ if (timerEventThread)
+ qFatal("%s: timerEventThread should be null", Q_FUNC_INFO);
timerEventThread = QThread::currentThread();
emit theSignal();
}
@@ -1327,7 +1347,8 @@ public:
public slots:
void theSlot()
{
- Q_ASSERT(slotThread == 0);
+ if (slotThread)
+ qFatal("%s: slotThread should be null", Q_FUNC_INFO);
slotThread = QThread::currentThread();
emit theSignal();
}
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 0e4b86d..d484b96 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -198,6 +198,7 @@ private slots:
#endif
void drawPixmapWhilePainterOpen();
+ void scaled_QTBUG19157();
};
static bool lenientCompare(const QPixmap &actual, const QPixmap &expected)
@@ -1698,8 +1699,8 @@ void tst_QPixmap::fromImageReaderAnimatedGif()
QImageReader referenceReader(path);
QImageReader pixmapReader(path);
- Q_ASSERT(referenceReader.canRead());
- Q_ASSERT(referenceReader.imageCount() > 1);
+ QVERIFY(referenceReader.canRead());
+ QVERIFY(referenceReader.imageCount() > 1);
for (int i = 0; i < referenceReader.imageCount(); ++i) {
QImage refImage = referenceReader.read();
@@ -1958,5 +1959,12 @@ void tst_QPixmap::drawPixmapWhilePainterOpen()
}
}
+void tst_QPixmap::scaled_QTBUG19157()
+{
+ QPixmap foo(5000, 1);
+ foo = foo.scaled(1024, 1024, Qt::KeepAspectRatio);
+ QVERIFY(!foo.isNull());
+}
+
QTEST_MAIN(tst_QPixmap)
#include "tst_qpixmap.moc"
diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp
index f0fd27a..91e0abe 100644
--- a/tests/auto/qprocess/tst_qprocess.cpp
+++ b/tests/auto/qprocess/tst_qprocess.cpp
@@ -668,7 +668,7 @@ void tst_QProcess::exitStatus()
QSKIP("This test opens a crash dialog on Windows", SkipSingle);
#endif
- Q_ASSERT(processList.count() == exitStatus.count());
+ QCOMPARE(exitStatus.count(), processList.count());
for (int i = 0; i < processList.count(); ++i) {
process->start(processList.at(i));
QVERIFY(process->waitForStarted(5000));
diff --git a/tests/auto/qrawfont/tst_qrawfont.cpp b/tests/auto/qrawfont/tst_qrawfont.cpp
index 4304f22..e0680c4 100644
--- a/tests/auto/qrawfont/tst_qrawfont.cpp
+++ b/tests/auto/qrawfont/tst_qrawfont.cpp
@@ -91,6 +91,9 @@ private slots:
void unsupportedWritingSystem_data();
void unsupportedWritingSystem();
+
+ void rawFontSetPixelSize_data();
+ void rawFontSetPixelSize();
#endif // QT_NO_RAWFONT
};
@@ -293,12 +296,12 @@ void tst_QRawFont::textLayout()
layout.createLine();
layout.endLayout();
- QList<QGlyphs> glyphss = layout.glyphs();
- QCOMPARE(glyphss.size(), 1);
+ QList<QGlyphRun> glyphRuns = layout.glyphRuns();
+ QCOMPARE(glyphRuns.size(), 1);
- QGlyphs glyphs = glyphss.at(0);
+ QGlyphRun glyphs = glyphRuns.at(0);
- QRawFont rawFont = glyphs.font();
+ QRawFont rawFont = glyphs.rawFont();
QVERIFY(rawFont.isValid());
QCOMPARE(rawFont.familyName(), familyName);
QCOMPARE(rawFont.pixelSize(), 18.0);
@@ -792,11 +795,11 @@ void tst_QRawFont::unsupportedWritingSystem()
layout.createLine();
layout.endLayout();
- QList<QGlyphs> glyphss = layout.glyphs();
- QCOMPARE(glyphss.size(), 1);
+ QList<QGlyphRun> glyphRuns = layout.glyphRuns();
+ QCOMPARE(glyphRuns.size(), 1);
- QGlyphs glyphs = glyphss.at(0);
- QRawFont layoutFont = glyphs.font();
+ QGlyphRun glyphs = glyphRuns.at(0);
+ QRawFont layoutFont = glyphs.rawFont();
QVERIFY(layoutFont.familyName() != QString::fromLatin1("QtBidiTestFont"));
QCOMPARE(layoutFont.pixelSize(), 12.0);
@@ -807,6 +810,39 @@ void tst_QRawFont::unsupportedWritingSystem()
fontDatabase.removeApplicationFont(id);
}
+void tst_QRawFont::rawFontSetPixelSize_data()
+{
+ QTest::addColumn<QFont::HintingPreference>("hintingPreference");
+
+ QTest::newRow("Default hinting preference") << QFont::PreferDefaultHinting;
+ QTest::newRow("No hinting preference") << QFont::PreferNoHinting;
+ QTest::newRow("Vertical hinting preference") << QFont::PreferVerticalHinting;
+ QTest::newRow("Full hinting preference") << QFont::PreferFullHinting;
+}
+
+void tst_QRawFont::rawFontSetPixelSize()
+{
+ QFETCH(QFont::HintingPreference, hintingPreference);
+
+ QTextLayout layout("Foobar");
+
+ QFont font = layout.font();
+ font.setHintingPreference(hintingPreference);
+ font.setPixelSize(12);
+ layout.setFont(font);
+
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QGlyphRun glyphs = layout.glyphRuns().at(0);
+ QRawFont rawFont = glyphs.rawFont();
+ QCOMPARE(rawFont.pixelSize(), 12.0);
+
+ rawFont.setPixelSize(24);
+ QCOMPARE(rawFont.pixelSize(), 24.0);
+}
+
#endif // QT_NO_RAWFONT
QTEST_MAIN(tst_QRawFont)
diff --git a/tests/auto/qreadwritelock/tst_qreadwritelock.cpp b/tests/auto/qreadwritelock/tst_qreadwritelock.cpp
index 99b6850..720f2b0 100644
--- a/tests/auto/qreadwritelock/tst_qreadwritelock.cpp
+++ b/tests/auto/qreadwritelock/tst_qreadwritelock.cpp
@@ -362,34 +362,45 @@ void tst_QReadWriteLock::tryWriteLock()
class Thread : public QThread
{
public:
+ Thread() : failureCount(0) { }
void run()
{
testsTurn.release();
threadsTurn.acquire();
- Q_ASSERT(!readWriteLock.tryLockForWrite());
+ if (readWriteLock.tryLockForWrite())
+ failureCount++;
testsTurn.release();
threadsTurn.acquire();
- Q_ASSERT(readWriteLock.tryLockForWrite());
- Q_ASSERT(lockCount.testAndSetRelaxed(0, 1));
- Q_ASSERT(lockCount.testAndSetRelaxed(1, 0));
+ if (!readWriteLock.tryLockForWrite())
+ failureCount++;
+ if (!lockCount.testAndSetRelaxed(0, 1))
+ failureCount++;
+ if (!lockCount.testAndSetRelaxed(1, 0))
+ failureCount++;
readWriteLock.unlock();
testsTurn.release();
threadsTurn.acquire();
- Q_ASSERT(!readWriteLock.tryLockForWrite(1000));
+ if (readWriteLock.tryLockForWrite(1000))
+ failureCount++;
testsTurn.release();
threadsTurn.acquire();
- Q_ASSERT(readWriteLock.tryLockForWrite(1000));
- Q_ASSERT(lockCount.testAndSetRelaxed(0, 1));
- Q_ASSERT(lockCount.testAndSetRelaxed(1, 0));
+ if (!readWriteLock.tryLockForWrite(1000))
+ failureCount++;
+ if (!lockCount.testAndSetRelaxed(0, 1))
+ failureCount++;
+ if (!lockCount.testAndSetRelaxed(1, 0))
+ failureCount++;
readWriteLock.unlock();
testsTurn.release();
threadsTurn.acquire();
}
+
+ int failureCount;
};
Thread thread;
@@ -419,6 +430,8 @@ void tst_QReadWriteLock::tryWriteLock()
testsTurn.acquire();
threadsTurn.release();
thread.wait();
+
+ QCOMPARE(thread.failureCount, 0);
}
}
diff --git a/tests/auto/qscriptable/tst_qscriptable.cpp b/tests/auto/qscriptable/tst_qscriptable.cpp
index 96b54bf..54ffbe9 100644
--- a/tests/auto/qscriptable/tst_qscriptable.cpp
+++ b/tests/auto/qscriptable/tst_qscriptable.cpp
@@ -137,8 +137,8 @@ int MyScriptable::getArgumentCount()
void MyScriptable::foo()
{
m_lastEngine = engine();
- QVERIFY(engine() != 0);
- context()->throwError("MyScriptable.foo");
+ if (engine())
+ context()->throwError("MyScriptable.foo");
}
void MyScriptable::evalIsBar()
@@ -164,15 +164,15 @@ void MyScriptable::setOtherEngine()
void MyScriptable::setX(int x)
{
m_lastEngine = engine();
- Q_ASSERT(engine());
- thisObject().setProperty("x", QScriptValue(engine(), x));
+ if (engine())
+ thisObject().setProperty("x", QScriptValue(engine(), x));
}
void MyScriptable::setX(const QString &x)
{
m_lastEngine = engine();
- Q_ASSERT(engine());
- thisObject().setProperty("x", QScriptValue(engine(), x));
+ if (engine())
+ thisObject().setProperty("x", QScriptValue(engine(), x));
}
void MyScriptable::setX2(int)
@@ -291,6 +291,7 @@ void tst_QScriptable::thisObject()
"o.setX(123);"
"o.__proto__ = Object.prototype;"
"o.x");
+ QCOMPARE(m_scriptable.lastEngine(), &m_engine);
QCOMPARE(ret.strictlyEquals(QScriptValue(&m_engine, 123)), true);
}
{
@@ -298,46 +299,55 @@ void tst_QScriptable::thisObject()
"o.setX2(456);"
"o.__proto__ = Object.prototype;"
"o.x");
+ QCOMPARE(m_scriptable.lastEngine(), &m_engine);
QCOMPARE(ret.strictlyEquals(QScriptValue(&m_engine, 456)), true);
}
m_engine.evaluate("o.__proto__ = scriptable");
{
QScriptValue ret = m_engine.evaluate("o.isBar()");
+ QCOMPARE(m_scriptable.lastEngine(), &m_engine);
QCOMPARE(ret.strictlyEquals(QScriptValue(&m_engine, false)), true);
}
{
QScriptValue ret = m_engine.evaluate("o.toString = function() { return 'foo@bar'; }; o.isBar()");
+ QCOMPARE(m_scriptable.lastEngine(), &m_engine);
QCOMPARE(ret.strictlyEquals(QScriptValue(&m_engine, true)), true);
}
// property getter
{
QScriptValue ret = m_engine.evaluate("scriptable.zab");
+ QCOMPARE(m_scriptable.lastEngine(), &m_engine);
QCOMPARE(ret.isQObject(), true);
QCOMPARE(ret.toQObject(), (QObject *)&m_scriptable);
}
{
QScriptValue ret = m_engine.evaluate("scriptable[1]");
+ QCOMPARE(m_scriptable.lastEngine(), &m_engine);
QCOMPARE(ret.isQObject(), true);
QCOMPARE(ret.toQObject(), (QObject *)&m_scriptable);
}
{
QScriptValue ret = m_engine.evaluate("o.zab");
+ QCOMPARE(m_scriptable.lastEngine(), &m_engine);
QCOMPARE(ret.toQObject(), (QObject *)0);
}
// property setter
{
QScriptValue ret = m_engine.evaluate("scriptable.setZab(null)");
+ QCOMPARE(m_scriptable.lastEngine(), &m_engine);
QCOMPARE(ret.isQObject(), true);
QCOMPARE(ret.toQObject(), (QObject *)&m_scriptable);
}
{
QVERIFY(!m_scriptable.oofThisObject().isValid());
m_engine.evaluate("o.oof = 123");
+ QCOMPARE(m_scriptable.lastEngine(), &m_engine);
QVERIFY(m_scriptable.oofThisObject().strictlyEquals(m_engine.evaluate("o")));
}
{
m_engine.evaluate("scriptable.oof = 123");
+ QCOMPARE(m_scriptable.lastEngine(), &m_engine);
QVERIFY(m_scriptable.oofThisObject().strictlyEquals(m_engine.evaluate("scriptable")));
}
@@ -345,13 +355,17 @@ void tst_QScriptable::thisObject()
{
{
QScriptValue ret = m_engine.evaluate("scriptable.sig.connect(o, scriptable.setX)");
+ QCOMPARE(m_scriptable.lastEngine(), &m_engine);
QVERIFY(ret.isUndefined());
}
QVERIFY(m_engine.evaluate("o.x").strictlyEquals(QScriptValue(&m_engine, 456)));
+ QCOMPARE(m_scriptable.lastEngine(), &m_engine);
m_scriptable.emitSig(654321);
QVERIFY(m_engine.evaluate("o.x").strictlyEquals(QScriptValue(&m_engine, 654321)));
+ QCOMPARE(m_scriptable.lastEngine(), &m_engine);
{
QScriptValue ret = m_engine.evaluate("scriptable.sig.disconnect(o, scriptable.setX)");
+ QCOMPARE(m_scriptable.lastEngine(), &m_engine);
QVERIFY(ret.isUndefined());
}
}
@@ -383,6 +397,7 @@ void tst_QScriptable::arguments()
void tst_QScriptable::throwError()
{
QScriptValue ret = m_engine.evaluate("scriptable.foo()");
+ QCOMPARE(m_scriptable.lastEngine(), &m_engine);
QCOMPARE(ret.isError(), true);
QCOMPARE(ret.toString(), QString("Error: MyScriptable.foo"));
}
diff --git a/tests/auto/qscriptclass/tst_qscriptclass.cpp b/tests/auto/qscriptclass/tst_qscriptclass.cpp
index 51a05c5..446c9fd 100644
--- a/tests/auto/qscriptclass/tst_qscriptclass.cpp
+++ b/tests/auto/qscriptclass/tst_qscriptclass.cpp
@@ -369,8 +369,7 @@ QVariant TestClass::extension(Extension extension,
{
m_lastExtensionType = extension;
m_lastExtensionArgument = argument;
- if (extension == Callable) {
- Q_ASSERT(m_callableMode != NotCallable);
+ if (extension == Callable && m_callableMode != NotCallable) {
QScriptContext *ctx = qvariant_cast<QScriptContext*>(argument);
if (m_callableMode == CallableReturnsSum) {
qsreal sum = 0;
@@ -398,8 +397,7 @@ QVariant TestClass::extension(Extension extension,
engine()->newQObject(ctx->thisObject(), engine());
return QVariant();
}
- } else if (extension == HasInstance) {
- Q_ASSERT(m_hasInstance);
+ } else if (extension == HasInstance && m_hasInstance) {
QScriptValueList args = qvariant_cast<QScriptValueList>(argument);
QScriptValue obj = args.at(0);
QScriptValue value = args.at(1);
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index 76c7a96..b92cd29 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -5701,7 +5701,10 @@ void tst_QScriptEngine::collectGarbageAfterNativeArguments()
static QScriptValue constructQObjectFromThisObject(QScriptContext *ctx, QScriptEngine *eng)
{
- Q_ASSERT(ctx->isCalledAsConstructor());
+ if (!ctx->isCalledAsConstructor()) {
+ qWarning("%s: ctx->isCalledAsConstructor() returned false", Q_FUNC_INFO);
+ return QScriptValue();
+ }
return eng->newQObject(ctx->thisObject(), new QObject, QScriptEngine::ScriptOwnership);
}
diff --git a/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp b/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp
index 3385740..142b0b7 100644
--- a/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp
+++ b/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp
@@ -76,9 +76,6 @@ public:
tst_QScriptEngineDebugger();
virtual ~tst_QScriptEngineDebugger();
-protected slots:
- void recordDebuggerStateAndContinue();
-
private slots:
void attachAndDetach();
void action();
@@ -89,9 +86,6 @@ private slots:
void multithreadedDebugging();
void autoShowStandardWindow();
void standardWindowOwnership();
-
-private:
- QScriptEngineDebugger::DebuggerState m_recordedDebuggerState;
};
tst_QScriptEngineDebugger::tst_QScriptEngineDebugger()
@@ -102,14 +96,6 @@ tst_QScriptEngineDebugger::~tst_QScriptEngineDebugger()
{
}
-void tst_QScriptEngineDebugger::recordDebuggerStateAndContinue()
-{
- QScriptEngineDebugger *debugger = qobject_cast<QScriptEngineDebugger*>(sender());
- Q_ASSERT(debugger != 0);
- m_recordedDebuggerState = debugger->state();
- debugger->action(QScriptEngineDebugger::ContinueAction)->trigger();
-}
-
void tst_QScriptEngineDebugger::attachAndDetach()
{
#if defined(Q_OS_WINCE) && _WIN32_WCE < 0x600
diff --git a/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp b/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp
index c720f00..b02d3ab 100644
--- a/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp
+++ b/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp
@@ -95,9 +95,11 @@ protected:
static QScriptValue qscript_fail(QScriptContext *ctx, QScriptEngine *eng)
{
QScriptValue realFail = ctx->callee().data();
- Q_ASSERT(realFail.isFunction());
+ if (!realFail.isFunction())
+ qFatal("%s: realFail must be a function", Q_FUNC_INFO);
QScriptValue ret = realFail.call(ctx->thisObject(), ctx->argumentsObject());
- Q_ASSERT(eng->hasUncaughtException());
+ if (!eng->hasUncaughtException())
+ qFatal("%s: realFail function did not throw an exception", Q_FUNC_INFO);
ret.setProperty("expected", ctx->argument(0));
ret.setProperty("actual", ctx->argument(1));
ret.setProperty("message", ctx->argument(2));
@@ -153,10 +155,14 @@ void tst_QScriptV8TestSuite::runTestFunction(int testIndex)
QScriptValue ret = engine.evaluate(contents);
if (engine.hasUncaughtException()) {
if (!ret.isError()) {
- Q_ASSERT(ret.instanceOf(engine.globalObject().property("MjsUnitAssertionError")));
+ int lineNumber = ret.property("lineNumber").toInt32();
+ QTest::qVerify(ret.instanceOf(engine.globalObject().property("MjsUnitAssertionError")),
+ ret.toString().toLatin1(),
+ "",
+ path.toLatin1(),
+ lineNumber);
QString actual = ret.property("actual").toString();
QString expected = ret.property("expected").toString();
- int lineNumber = ret.property("lineNumber").toInt32();
QString failMessage;
if (shouldGenerateExpectedFailures) {
if (ret.property("message").isString())
diff --git a/tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp b/tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp
index 5968c64..2aec22f 100644
--- a/tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp
+++ b/tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp
@@ -467,7 +467,7 @@ QString generateCastDef<qsreal>(const QList<QPair<QString, qsreal> >& list)
QString::number(list.count()));
}
-static QString generateCompareDef(const QString& comparisionType, const QList<QString> tags)
+static QString generateCompareDef(const QString& comparisonType, const QList<QString> tags)
{
static const QString templ = "\n"\
"void tst_QScriptValueGenerated::%1_initData()\n"\
@@ -501,10 +501,11 @@ static QString generateCompareDef(const QString& comparisionType, const QList<QS
"}\n"\
"\n"\
"DEFINE_TEST_FUNCTION(%1)\n";
- Q_ASSERT(comparisionType == "strictlyEquals"
- || comparisionType == "equals"
- || comparisionType == "lessThan"
- || comparisionType == "instanceOf");
+ if (comparisonType != "strictlyEquals"
+ && comparisonType != "equals"
+ && comparisonType != "lessThan"
+ && comparisonType != "instanceOf")
+ qFatal("%s: Unknown comparisonType: %s", Q_FUNC_INFO, qPrintable(comparisonType));
QString result = templ;
QStringList set;
@@ -516,7 +517,7 @@ static QString generateCompareDef(const QString& comparisionType, const QList<QS
set.append(escape(tmp));
set.append("\"");
}
- return result.arg(comparisionType, set.join(""), QString::number(tags.count()));
+ return result.arg(comparisonType, set.join(""), QString::number(tags.count()));
}
static QString generateInitDef(const QVector<QString>& allDataTags)
@@ -545,6 +546,17 @@ static void squashTags(QString dataTag, const QVector<bool>& results, QList<QStr
}
}
+static QString streamStatusString(QDataStream::Status s)
+{
+ switch (s) {
+ case QDataStream::ReadPastEnd:
+ return QString("ReadPastEnd");
+ case QDataStream::ReadCorruptData:
+ return QString("ReadCorruptData");
+ default:
+ return QString("Unknown (%1)").arg(static_cast<int>(s));
+ }
+}
QHash<QString, QString> TestGenerator::generateTest()
{
@@ -596,7 +608,10 @@ QHash<QString, QString> TestGenerator::generateTest()
m_tempFile.seek(0);
QDataStream in(&m_tempFile);
in >> dataTags;
- Q_ASSERT(in.status() == in.Ok);
+ if (in.status() != in.Ok)
+ qFatal("%s: stream has bad status %s after reading dataTags",
+ Q_FUNC_INFO,
+ qPrintable(streamStatusString(in.status())));
while(!in.atEnd())
{
@@ -720,10 +735,13 @@ QHash<QString, QString> TestGenerator::generateTest()
castUInt32List.append(QPair<QString, quint32>(dataTag, castUInt32Res));
castUInt16List.append(QPair<QString, quint16>(dataTag, castUInt16Res));
- Q_ASSERT(in.status() == in.Ok);
+ if (in.status() != in.Ok)
+ qFatal("%s: stream has bad status %s after reading data items",
+ Q_FUNC_INFO,
+ qPrintable(streamStatusString(in.status())));
}
-
- Q_ASSERT(in.atEnd());
+ if (!in.atEnd())
+ qFatal("%s: stream has more data after reading all data items", Q_FUNC_INFO);
// Generate.
QHash<QString, QString> result;
diff --git a/tests/auto/qscriptvaluegenerated/testgen/testgenerator.h b/tests/auto/qscriptvaluegenerated/testgen/testgenerator.h
index c9169c6..0dc3f18 100644
--- a/tests/auto/qscriptvaluegenerated/testgen/testgenerator.h
+++ b/tests/auto/qscriptvaluegenerated/testgen/testgenerator.h
@@ -59,7 +59,8 @@ public:
void run()
{
prepareData();
- Q_ASSERT(m_tempFile.size());
+ if (!m_tempFile.size())
+ qFatal("%s: prepareData failed to generate any data", Q_FUNC_INFO);
save(generateTest());
}
diff --git a/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp b/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp
index 1f1eb64..fa43c0f 100644
--- a/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp
+++ b/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp
@@ -106,7 +106,7 @@ void tst_QScriptValueIterator::iterateForward()
QFETCH(QStringList, propertyNames);
QFETCH(QStringList, propertyValues);
QMap<QString, QString> pmap;
- Q_ASSERT(propertyNames.size() == propertyValues.size());
+ QVERIFY(propertyNames.size() == propertyValues.size());
QScriptEngine engine;
QScriptValue object = engine.newObject();
@@ -165,7 +165,7 @@ void tst_QScriptValueIterator::iterateBackward()
QFETCH(QStringList, propertyNames);
QFETCH(QStringList, propertyValues);
QMap<QString, QString> pmap;
- Q_ASSERT(propertyNames.size() == propertyValues.size());
+ QVERIFY(propertyNames.size() == propertyValues.size());
QScriptEngine engine;
QScriptValue object = engine.newObject();
diff --git a/tests/auto/qscroller/qscroller.pro b/tests/auto/qscroller/qscroller.pro
deleted file mode 100644
index 845dcb9..0000000
--- a/tests/auto/qscroller/qscroller.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-load(qttest_p4)
-
-SOURCES += tst_qscroller.cpp
diff --git a/tests/auto/qscroller/tst_qscroller.cpp b/tests/auto/qscroller/tst_qscroller.cpp
deleted file mode 100644
index aab91a6..0000000
--- a/tests/auto/qscroller/tst_qscroller.cpp
+++ /dev/null
@@ -1,537 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui>
-#include <QtTest>
-// #include <QDebug>
-
-class tst_QScrollerWidget : public QWidget
-{
-public:
- tst_QScrollerWidget()
- : QWidget()
- {
- reset();
- }
-
- void reset()
- {
- receivedPrepare = false;
- receivedScroll = false;
- receivedFirst = false;
- receivedLast = false;
- receivedOvershoot = false;
- }
-
- bool event(QEvent *e)
- {
- switch (e->type()) {
- case QEvent::Gesture:
- e->setAccepted(false); // better reject the event or QGestureManager will make trouble
- return false;
-
- case QEvent::ScrollPrepare:
- {
- receivedPrepare = true;
- QScrollPrepareEvent *se = static_cast<QScrollPrepareEvent *>(e);
- se->setViewportSize(QSizeF(100,100));
- se->setContentPosRange(scrollArea);
- se->setContentPos(scrollPosition);
- se->accept();
- return true;
- }
-
- case QEvent::Scroll:
- {
- receivedScroll = true;
- QScrollEvent *se = static_cast<QScrollEvent *>(e);
- // qDebug() << "Scroll for"<<this<<"pos"<<se->scrollPos()<<"ov"<<se->overshoot()<<"first"<<se->isFirst()<<"last"<<se->isLast();
-
- if (se->scrollState() == QScrollEvent::ScrollStarted)
- receivedFirst = true;
- if (se->scrollState() == QScrollEvent::ScrollFinished)
- receivedLast = true;
-
- currentPos = se->contentPos();
- overshoot = se->overshootDistance();
- if (!qFuzzyCompare( overshoot.x() + 1.0, 1.0 ) ||
- !qFuzzyCompare( overshoot.y() + 1.0, 1.0 ))
- receivedOvershoot = true;
- return true;
- }
-
- default:
- return QObject::event(e);
- }
- }
-
-
- QRectF scrollArea;
- QPointF scrollPosition;
-
- bool receivedPrepare;
- bool receivedScroll;
- bool receivedFirst;
- bool receivedLast;
- bool receivedOvershoot;
-
- QPointF currentPos;
- QPointF overshoot;
-};
-
-
-class tst_QScroller : public QObject
-{
- Q_OBJECT
-public:
- tst_QScroller() { }
- ~tst_QScroller() { }
-
-private:
- void kineticScroll( tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd);
- void kineticScrollNoTest( tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd);
-
-private slots:
- void staticScrollers();
- void scrollerProperties();
- void scrollTo();
- void scroll();
- void overshoot();
-};
-
-/*! \internal
- Generates touchBegin, touchUpdate and touchEnd events to trigger scrolling.
- Tests some in between states but does not wait until scrolling is finished.
-*/
-void tst_QScroller::kineticScroll( tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd)
-{
- sw->scrollPosition = from;
- sw->currentPos= from;
-
- QScroller *s1 = QScroller::scroller(sw);
- QCOMPARE( s1->state(), QScroller::Inactive );
-
- QScrollerProperties sp1 = QScroller::scroller(sw)->scrollerProperties();
- int fps = 60;
-
- QTouchEvent::TouchPoint rawTouchPoint;
- rawTouchPoint.setId(0);
-
- // send the touch begin event
- QTouchEvent::TouchPoint touchPoint(0);
- touchPoint.setState(Qt::TouchPointPressed);
- touchPoint.setPos(touchStart);
- touchPoint.setScenePos(touchStart);
- touchPoint.setScreenPos(touchStart);
- QTouchEvent touchEvent1(QEvent::TouchBegin,
- QTouchEvent::TouchScreen,
- Qt::NoModifier,
- Qt::TouchPointPressed,
- (QList<QTouchEvent::TouchPoint>() << touchPoint));
- QApplication::sendEvent(sw, &touchEvent1);
-
- QCOMPARE( s1->state(), QScroller::Pressed );
-
- // send the touch update far enough to trigger a scroll
- QTest::qWait(200); // we need to wait a little or else the speed would be infinite. now we have around 500 pixel per second.
- touchPoint.setPos(touchUpdate);
- touchPoint.setScenePos(touchUpdate);
- touchPoint.setScreenPos(touchUpdate);
- QTouchEvent touchEvent2(QEvent::TouchUpdate,
- QTouchEvent::TouchScreen,
- Qt::NoModifier,
- Qt::TouchPointMoved,
- (QList<QTouchEvent::TouchPoint>() << touchPoint));
- QApplication::sendEvent(sw, &touchEvent2);
-
- QCOMPARE( s1->state(), QScroller::Dragging );
- QCOMPARE( sw->receivedPrepare, true );
-
-
- QTest::qWait(1000 / fps * 2); // wait until the first scroll move
- QCOMPARE( sw->receivedFirst, true );
- QCOMPARE( sw->receivedScroll, true );
- QCOMPARE( sw->receivedOvershoot, false );
-
- // note that the scrolling goes in a different direction than the mouse move
- QPoint calculatedPos = from.toPoint() - touchUpdate - touchStart;
- QVERIFY(qAbs(sw->currentPos.x() - calculatedPos.x()) < 1.0);
- QVERIFY(qAbs(sw->currentPos.y() - calculatedPos.y()) < 1.0);
-
- // send the touch end
- touchPoint.setPos(touchEnd);
- touchPoint.setScenePos(touchEnd);
- touchPoint.setScreenPos(touchEnd);
- QTouchEvent touchEvent5(QEvent::TouchEnd,
- QTouchEvent::TouchScreen,
- Qt::NoModifier,
- Qt::TouchPointReleased,
- (QList<QTouchEvent::TouchPoint>() << touchPoint));
- QApplication::sendEvent(sw, &touchEvent5);
-}
-
-/*! \internal
- Generates touchBegin, touchUpdate and touchEnd events to trigger scrolling.
- This function does not have any in between tests, it does not expect the scroller to actually scroll.
-*/
-void tst_QScroller::kineticScrollNoTest( tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd)
-{
- sw->scrollPosition = from;
- sw->currentPos = from;
-
- QScroller *s1 = QScroller::scroller(sw);
- QCOMPARE( s1->state(), QScroller::Inactive );
-
- QScrollerProperties sp1 = s1->scrollerProperties();
- int fps = 60;
-
- QTouchEvent::TouchPoint rawTouchPoint;
- rawTouchPoint.setId(0);
-
- // send the touch begin event
- QTouchEvent::TouchPoint touchPoint(0);
- touchPoint.setState(Qt::TouchPointPressed);
- touchPoint.setPos(touchStart);
- touchPoint.setScenePos(touchStart);
- touchPoint.setScreenPos(touchStart);
- QTouchEvent touchEvent1(QEvent::TouchBegin,
- QTouchEvent::TouchScreen,
- Qt::NoModifier,
- Qt::TouchPointPressed,
- (QList<QTouchEvent::TouchPoint>() << touchPoint));
- QApplication::sendEvent(sw, &touchEvent1);
-
- // send the touch update far enough to trigger a scroll
- QTest::qWait(200); // we need to wait a little or else the speed would be infinite. now we have around 500 pixel per second.
- touchPoint.setPos(touchUpdate);
- touchPoint.setScenePos(touchUpdate);
- touchPoint.setScreenPos(touchUpdate);
- QTouchEvent touchEvent2(QEvent::TouchUpdate,
- QTouchEvent::TouchScreen,
- Qt::NoModifier,
- Qt::TouchPointMoved,
- (QList<QTouchEvent::TouchPoint>() << touchPoint));
- QApplication::sendEvent(sw, &touchEvent2);
-
- QTest::qWait(1000 / fps * 2); // wait until the first scroll move
-
- // send the touch end
- touchPoint.setPos(touchEnd);
- touchPoint.setScenePos(touchEnd);
- touchPoint.setScreenPos(touchEnd);
- QTouchEvent touchEvent5(QEvent::TouchEnd,
- QTouchEvent::TouchScreen,
- Qt::NoModifier,
- Qt::TouchPointReleased,
- (QList<QTouchEvent::TouchPoint>() << touchPoint));
- QApplication::sendEvent(sw, &touchEvent5);
-}
-
-
-void tst_QScroller::staticScrollers()
-{
- // scrollers
- {
- QObject *o1 = new QObject(this);
- QObject *o2 = new QObject(this);
-
- // get scroller for object
- QScroller *s1 = QScroller::scroller(o1);
- QScroller *s2 = QScroller::scroller(o2);
-
- QVERIFY(s1);
- QVERIFY(s2);
- QVERIFY(s1 != s2);
-
- QVERIFY(!QScroller::scroller(static_cast<const QObject*>(0)));
- QCOMPARE(QScroller::scroller(o1), s1);
-
- delete o1;
- delete o2;
- }
-
- // the same for properties
- {
- QObject *o1 = new QObject(this);
- QObject *o2 = new QObject(this);
-
- // get scroller for object
- QScrollerProperties sp1 = QScroller::scroller(o1)->scrollerProperties();
- QScrollerProperties sp2 = QScroller::scroller(o2)->scrollerProperties();
-
- // default properties should be the same
- QVERIFY(sp1 == sp2);
-
- QCOMPARE(QScroller::scroller(o1)->scrollerProperties(), sp1);
-
- delete o1;
- delete o2;
- }
-}
-
-void tst_QScroller::scrollerProperties()
-{
- QObject *o1 = new QObject(this);
- QScrollerProperties sp1 = QScroller::scroller(o1)->scrollerProperties();
-
- QScrollerProperties::ScrollMetric metrics[] =
- {
- QScrollerProperties::MousePressEventDelay, // qreal [s]
- QScrollerProperties::DragStartDistance, // qreal [m]
- QScrollerProperties::DragVelocitySmoothingFactor, // qreal [0..1/s] (complex calculation involving time) v = v_new* DASF + v_old * (1-DASF)
- QScrollerProperties::AxisLockThreshold, // qreal [0..1] atan(|min(dx,dy)|/|max(dx,dy)|)
-
- QScrollerProperties::DecelerationFactor, // slope of the curve
-
- QScrollerProperties::MinimumVelocity, // qreal [m/s]
- QScrollerProperties::MaximumVelocity, // qreal [m/s]
- QScrollerProperties::MaximumClickThroughVelocity, // qreal [m/s]
-
- QScrollerProperties::AcceleratingFlickMaximumTime, // qreal [s]
- QScrollerProperties::AcceleratingFlickSpeedupFactor, // qreal [1..]
-
- QScrollerProperties::SnapPositionRatio, // qreal [0..1]
- QScrollerProperties::SnapTime, // qreal [s]
-
- QScrollerProperties::OvershootDragResistanceFactor, // qreal [0..1]
- QScrollerProperties::OvershootDragDistanceFactor, // qreal [0..1]
- QScrollerProperties::OvershootScrollDistanceFactor, // qreal [0..1]
- QScrollerProperties::OvershootScrollTime, // qreal [s]
- };
-
- for (unsigned int i = 0; i < sizeof(metrics) / sizeof(metrics[0]); i++) {
- sp1.setScrollMetric(metrics[i], 0.9);
- QCOMPARE(sp1.scrollMetric(metrics[i]).toDouble(), 0.9);
- }
- sp1.setScrollMetric(QScrollerProperties::ScrollingCurve, QEasingCurve(QEasingCurve::OutQuart));
- QCOMPARE(sp1.scrollMetric(QScrollerProperties::ScrollingCurve).toEasingCurve().type(), QEasingCurve::OutQuart);
-
- sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOff));
- QCOMPARE(sp1.scrollMetric(QScrollerProperties::HorizontalOvershootPolicy).value<QScrollerProperties::OvershootPolicy>(), QScrollerProperties::OvershootAlwaysOff);
-
- sp1.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOn));
- QCOMPARE(sp1.scrollMetric(QScrollerProperties::VerticalOvershootPolicy).value<QScrollerProperties::OvershootPolicy>(), QScrollerProperties::OvershootAlwaysOn);
-
- sp1.setScrollMetric(QScrollerProperties::FrameRate, QVariant::fromValue(QScrollerProperties::Fps20));
- QCOMPARE(sp1.scrollMetric(QScrollerProperties::FrameRate).value<QScrollerProperties::FrameRates>(), QScrollerProperties::Fps20);
-}
-
-void tst_QScroller::scrollTo()
-{
- {
- tst_QScrollerWidget *sw = new tst_QScrollerWidget();
- sw->scrollArea = QRectF( 0, 0, 1000, 1000 );
- sw->scrollPosition = QPointF( 500, 500 );
-
- QScroller *s1 = QScroller::scroller(sw);
- QCOMPARE( s1->state(), QScroller::Inactive );
-
- // a normal scroll
- s1->scrollTo(QPointF(100,100), 100);
- QTest::qWait(200);
-
- QCOMPARE( sw->receivedPrepare, true );
- QCOMPARE( sw->receivedScroll, true );
- QCOMPARE( sw->receivedFirst, true );
- QCOMPARE( sw->receivedLast, true );
- QCOMPARE( sw->receivedOvershoot, false );
- QVERIFY(qFuzzyCompare( sw->currentPos.x(), 100 ));
- QVERIFY(qFuzzyCompare( sw->currentPos.y(), 100 ));
-
- delete sw;
- }
-}
-
-void tst_QScroller::scroll()
-{
-#if defined(Q_OS_MACX) && (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6)
- QSKIP("Mac OS X < 10.6 does not support QTouchEvents", SkipAll);
- return;
-#endif
-
-#ifndef QT_NO_GESTURES
- // -- good case. normal scroll
- tst_QScrollerWidget *sw = new tst_QScrollerWidget();
- sw->scrollArea = QRectF(0, 0, 1000, 1000);
- QScroller::grabGesture(sw, QScroller::TouchGesture);
- sw->setGeometry(100, 100, 400, 300);
-
- QScroller *s1 = QScroller::scroller(sw);
- kineticScroll(sw, QPointF(500, 500), QPoint(0, 0), QPoint(100, 100), QPoint(200, 200));
- // now we should be scrolling
- QCOMPARE( s1->state(), QScroller::Scrolling );
-
- // wait until finished, check that no further first scroll is send
- sw->receivedFirst = false;
- sw->receivedScroll = false;
- while (s1->state() == QScroller::Scrolling)
- QTest::qWait(100);
-
- QCOMPARE( sw->receivedFirst, false );
- QCOMPARE( sw->receivedScroll, true );
- QCOMPARE( sw->receivedLast, true );
- QVERIFY(sw->currentPos.x() < 400);
- QVERIFY(sw->currentPos.y() < 400);
-
- // -- try to scroll when nothing to scroll
-
- sw->reset();
- sw->scrollArea = QRectF(0, 0, 0, 1000);
- kineticScrollNoTest(sw, QPointF(0, 500), QPoint(0, 0), QPoint(100, 0), QPoint(200, 0));
-
- while (s1->state() != QScroller::Inactive)
- QTest::qWait(20);
-
- QCOMPARE(sw->currentPos.x(), 0.0);
- QCOMPARE(sw->currentPos.y(), 500.0);
-
- delete sw;
-#endif
-}
-
-void tst_QScroller::overshoot()
-{
-#if defined(Q_OS_MACX) && (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6)
- QSKIP("Mac OS X < 10.6 does not support QTouchEvents", SkipAll);
- return;
-#endif
-
-#ifndef QT_NO_GESTURES
- tst_QScrollerWidget *sw = new tst_QScrollerWidget();
- sw->scrollArea = QRectF(0, 0, 1000, 1000);
- QScroller::grabGesture(sw, QScroller::TouchGesture);
- sw->setGeometry(100, 100, 400, 300);
-
- QScroller *s1 = QScroller::scroller(sw);
- QScrollerProperties sp1 = s1->scrollerProperties();
-
- sp1.setScrollMetric(QScrollerProperties::OvershootDragResistanceFactor, 0.5);
- sp1.setScrollMetric(QScrollerProperties::OvershootDragDistanceFactor, 0.2);
- sp1.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, 0.2);
-
- // -- try to scroll with overshoot (when scrollable good case)
-
- sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootWhenScrollable));
- s1->setScrollerProperties(sp1);
- kineticScrollNoTest(sw, QPointF(500, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0));
-
- while (s1->state() != QScroller::Inactive)
- QTest::qWait(20);
-
- //qDebug() << "Overshoot fuzzy: "<<sw->currentPos;
- QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 ));
- QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 ));
- QCOMPARE( sw->receivedOvershoot, true );
-
- // -- try to scroll with overshoot (when scrollable bad case)
- sw->reset();
- sw->scrollArea = QRectF(0, 0, 0, 1000);
-
- sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootWhenScrollable));
- s1->setScrollerProperties(sp1);
- kineticScrollNoTest(sw, QPointF(0, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0));
-
- while (s1->state() != QScroller::Inactive)
- QTest::qWait(20);
-
- //qDebug() << "Overshoot fuzzy: "<<sw->currentPos;
- QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 ));
- QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 ));
- QCOMPARE( sw->receivedOvershoot, false );
-
- // -- try to scroll with overshoot (always on)
- sw->reset();
- sw->scrollArea = QRectF(0, 0, 0, 1000);
-
- sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOn));
- s1->setScrollerProperties(sp1);
- kineticScrollNoTest(sw, QPointF(0, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0));
-
- while (s1->state() != QScroller::Inactive)
- QTest::qWait(20);
-
- //qDebug() << "Overshoot fuzzy: "<<sw->currentPos;
-
- QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 ));
- QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 ));
- QCOMPARE( sw->receivedOvershoot, true );
-
- // -- try to scroll with overshoot (always off)
- sw->reset();
- sw->scrollArea = QRectF(0, 0, 1000, 1000);
-
- sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOff));
- s1->setScrollerProperties(sp1);
- kineticScrollNoTest(sw, QPointF(500, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0));
-
- while (s1->state() != QScroller::Inactive)
- QTest::qWait(20);
-
- QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 ));
- QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 ));
- QCOMPARE( sw->receivedOvershoot, false );
-
- // -- try to scroll with overshoot (always on but max overshoot = 0)
- sp1.setScrollMetric(QScrollerProperties::OvershootDragDistanceFactor, 0.0);
- sp1.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, 0.0);
- sw->reset();
- sw->scrollArea = QRectF(0, 0, 1000, 1000);
-
- sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOn));
- s1->setScrollerProperties(sp1);
- kineticScrollNoTest(sw, QPointF(500, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0));
-
- while (s1->state() != QScroller::Inactive)
- QTest::qWait(20);
-
- QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 ));
- QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 ));
- QCOMPARE( sw->receivedOvershoot, false );
-
-
- delete sw;
-#endif
-}
-
-
-QTEST_MAIN(tst_QScroller)
-
-#include "tst_qscroller.moc"
diff --git a/tests/auto/qsharedpointer/externaltests.cpp b/tests/auto/qsharedpointer/externaltests.cpp
index 013fdf2..d551be3 100644
--- a/tests/auto/qsharedpointer/externaltests.cpp
+++ b/tests/auto/qsharedpointer/externaltests.cpp
@@ -50,6 +50,7 @@
#include <QtCore/QDir>
#include <QtCore/QDirIterator>
#include <QtCore/QDateTime>
+#include <QtCore/QDebug>
#ifdef Q_OS_SYMBIAN
#define DEFAULT_MAKESPEC "X:/STLsupport/mkspecs/symbian-abld/"
@@ -342,7 +343,8 @@ namespace QTest {
void QExternalTestPrivate::removeTemporaryDirectory()
{
- Q_ASSERT(!temporaryDir.isEmpty());
+ if (temporaryDir.isEmpty())
+ qWarning() << "Temporary directory is expected to be non-empty";
removeRecursive(temporaryDir);
temporaryDir.clear();
}
@@ -487,7 +489,8 @@ namespace QTest {
bool QExternalTestPrivate::createProjectFile()
{
- Q_ASSERT(!temporaryDir.isEmpty());
+ if (temporaryDir.isEmpty())
+ qWarning() << "Temporary directory is expected to be non-empty";
QFile projectFile(temporaryDir + QLatin1String("/project.pro"));
if (!projectFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
@@ -599,7 +602,9 @@ namespace QTest {
bool QExternalTestPrivate::runQmake()
{
- Q_ASSERT(!temporaryDir.isEmpty());
+ if (temporaryDir.isEmpty())
+ qWarning() << "Temporary directory is expected to be non-empty";
+
if (!createProjectFile())
return false;
@@ -633,7 +638,8 @@ namespace QTest {
bool QExternalTestPrivate::runMake(Target target)
{
- Q_ASSERT(!temporaryDir.isEmpty());
+ if (temporaryDir.isEmpty())
+ qWarning() << "Temporary directory is expected to be non-empty";
QExternalProcess make;
make.setWorkingDirectory(temporaryDir);
diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
index 8fba1db..27d2d4d 100644
--- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
@@ -139,7 +139,8 @@ public:
virtual ~Data()
{
- Q_ASSERT_X(generation > 0, "tst_QSharedPointer", "Double deletion!");
+ if (generation <= 0)
+ qFatal("tst_qsharedpointer: Double deletion!");
generation = 0;
++destructorCounter;
}
@@ -283,8 +284,8 @@ void tst_QSharedPointer::operators()
QSharedPointer<char> p1;
QSharedPointer<char> p2(new char);
qptrdiff diff = p2.data() - p1.data();
- Q_ASSERT(p1.data() != p2.data());
- Q_ASSERT(diff != 0);
+ QVERIFY(p1.data() != p2.data());
+ QVERIFY(diff != 0);
// operator-
QCOMPARE(p2 - p1.data(), diff);
@@ -867,8 +868,8 @@ void tst_QSharedPointer::differentPointers()
{
DiffPtrDerivedData *aData = new DiffPtrDerivedData;
Data *aBase = aData;
- Q_ASSERT(aData == aBase);
- Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
+ QVERIFY(aData == aBase);
+ QVERIFY(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
QSharedPointer<Data> baseptr = QSharedPointer<Data>(aData);
QSharedPointer<DiffPtrDerivedData> ptr = qSharedPointerCast<DiffPtrDerivedData>(baseptr);
@@ -885,8 +886,8 @@ void tst_QSharedPointer::differentPointers()
{
DiffPtrDerivedData *aData = new DiffPtrDerivedData;
Data *aBase = aData;
- Q_ASSERT(aData == aBase);
- Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
+ QVERIFY(aData == aBase);
+ QVERIFY(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
QSharedPointer<DiffPtrDerivedData> ptr = QSharedPointer<DiffPtrDerivedData>(aData);
QSharedPointer<Data> baseptr = ptr;
@@ -908,8 +909,8 @@ void tst_QSharedPointer::virtualBaseDifferentPointers()
{
VirtualDerived *aData = new VirtualDerived;
Data *aBase = aData;
- Q_ASSERT(aData == aBase);
- Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
+ QVERIFY(aData == aBase);
+ QVERIFY(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
QSharedPointer<VirtualDerived> ptr = QSharedPointer<VirtualDerived>(aData);
QSharedPointer<Data> baseptr = qSharedPointerCast<Data>(ptr);
@@ -928,8 +929,8 @@ void tst_QSharedPointer::virtualBaseDifferentPointers()
{
VirtualDerived *aData = new VirtualDerived;
Data *aBase = aData;
- Q_ASSERT(aData == aBase);
- Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
+ QVERIFY(aData == aBase);
+ QVERIFY(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase));
QSharedPointer<VirtualDerived> ptr = QSharedPointer<VirtualDerived>(aData);
QSharedPointer<Data> baseptr = ptr;
@@ -1605,7 +1606,7 @@ void hashAndMapTest()
QVERIFY(it != c.find(Key()));
if (Ordered) {
- Q_ASSERT(k0 < k1);
+ QVERIFY(k0 < k1);
it = c.begin();
QCOMPARE(it.key(), k0);
diff --git a/tests/auto/qsplitter/tst_qsplitter.cpp b/tests/auto/qsplitter/tst_qsplitter.cpp
index a72973d..473018d 100644
--- a/tests/auto/qsplitter/tst_qsplitter.cpp
+++ b/tests/auto/qsplitter/tst_qsplitter.cpp
@@ -1340,14 +1340,14 @@ void tst_QSplitter::task187373_addAbstractScrollAreas()
QFETCH(QString, className);
QFETCH(bool, addInConstructor);
QFETCH(bool, addOutsideConstructor);
- Q_ASSERT(addInConstructor || addOutsideConstructor);
+ QVERIFY(addInConstructor || addOutsideConstructor);
QSplitter *splitter = new QSplitter;
splitter->show();
- Q_ASSERT(splitter->isVisible());
+ QVERIFY(splitter->isVisible());
QAbstractScrollArea *w = task187373_createScrollArea(splitter, className, addInConstructor);
- Q_ASSERT(w);
+ QVERIFY(w);
if (addOutsideConstructor)
splitter->addWidget(w);
diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
index e6a9337..91fd5a1 100644
--- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
@@ -767,7 +767,7 @@ void tst_QSqlDatabase::checkValues(const FieldDef fieldDefs[], QSqlDatabase db)
Q3SqlCursor cur(qTableName("qtestfields", __FILE__), true, db);
QVERIFY_SQL(cur, select());
QSqlRecord* rec = cur.primeInsert();
- Q_ASSERT(rec);
+ QVERIFY(rec);
rec->setValue("id", pkey++);
int i = 0;
for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) {
@@ -828,7 +828,7 @@ void tst_QSqlDatabase::checkNullValues(const FieldDef fieldDefs[], QSqlDatabase
Q3SqlCursor cur(qTableName("qtestfields", __FILE__), true, db);
QVERIFY_SQL(cur, select());
QSqlRecord* rec = cur.primeInsert();
- Q_ASSERT(rec);
+ QVERIFY(rec);
rec->setValue("id", pkey++);
int i = 0;
for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) {
diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp
index 9f85319..5a5bdcc 100644
--- a/tests/auto/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp
@@ -156,6 +156,7 @@ private slots:
void setSslConfiguration_data();
void setSslConfiguration();
void waitForEncrypted();
+ void waitForEncryptedMinusOne();
void waitForConnectedEncryptedReadyRead();
void startClientEncryption();
void startServerEncryption();
@@ -1098,6 +1099,20 @@ void tst_QSslSocket::waitForEncrypted()
QVERIFY(socket->waitForEncrypted(10000));
}
+void tst_QSslSocket::waitForEncryptedMinusOne()
+{
+ if (!QSslSocket::supportsSsl())
+ return;
+
+ QSslSocketPtr socket = newSocket();
+ this->socket = socket;
+
+ connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot()));
+ socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
+
+ QVERIFY(socket->waitForEncrypted(-1));
+}
+
void tst_QSslSocket::waitForConnectedEncryptedReadyRead()
{
if (!QSslSocket::supportsSsl())
@@ -1565,8 +1580,8 @@ protected:
// delayed start of encryption
QTest::qSleep(100);
QSslSocket *socket = server.socket;
- QVERIFY(socket);
- QVERIFY(socket->isValid());
+ if (!socket || !socket->isValid())
+ return; // error
socket->ignoreSslErrors();
socket->startServerEncryption();
if (!socket->waitForEncrypted(2000))
diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp
index 8e0fb78..11fd986 100644
--- a/tests/auto/qstring/tst_qstring.cpp
+++ b/tests/auto/qstring/tst_qstring.cpp
@@ -3429,9 +3429,9 @@ void tst_QString::fromLatin1Roundtrip()
QFETCH(QString, unicode);
// QtTest safety check:
- Q_ASSERT(latin1.isNull() == unicode.isNull());
- Q_ASSERT(latin1.isEmpty() == unicode.isEmpty());
- Q_ASSERT(latin1.length() == unicode.length());
+ QCOMPARE(latin1.isNull(), unicode.isNull());
+ QCOMPARE(latin1.isEmpty(), unicode.isEmpty());
+ QCOMPARE(latin1.length(), unicode.length());
if (!latin1.isEmpty())
while (latin1.length() < 128) {
@@ -3484,12 +3484,12 @@ void tst_QString::toLatin1Roundtrip()
QFETCH(QString, unicodedst);
// QtTest safety check:
- Q_ASSERT(latin1.isNull() == unicodesrc.isNull());
- Q_ASSERT(latin1.isEmpty() == unicodesrc.isEmpty());
- Q_ASSERT(latin1.length() == unicodesrc.length());
- Q_ASSERT(latin1.isNull() == unicodedst.isNull());
- Q_ASSERT(latin1.isEmpty() == unicodedst.isEmpty());
- Q_ASSERT(latin1.length() == unicodedst.length());
+ QCOMPARE(latin1.isNull(), unicodesrc.isNull());
+ QCOMPARE(latin1.isEmpty(), unicodesrc.isEmpty());
+ QCOMPARE(latin1.length(), unicodesrc.length());
+ QCOMPARE(latin1.isNull(), unicodedst.isNull());
+ QCOMPARE(latin1.isEmpty(), unicodedst.isEmpty());
+ QCOMPARE(latin1.length(), unicodedst.length());
if (!latin1.isEmpty())
while (latin1.length() < 128) {
@@ -3519,12 +3519,12 @@ void tst_QString::stringRef_toLatin1Roundtrip()
QFETCH(QString, unicodedst);
// QtTest safety check:
- Q_ASSERT(latin1.isNull() == unicodesrc.isNull());
- Q_ASSERT(latin1.isEmpty() == unicodesrc.isEmpty());
- Q_ASSERT(latin1.length() == unicodesrc.length());
- Q_ASSERT(latin1.isNull() == unicodedst.isNull());
- Q_ASSERT(latin1.isEmpty() == unicodedst.isEmpty());
- Q_ASSERT(latin1.length() == unicodedst.length());
+ QCOMPARE(latin1.isNull(), unicodesrc.isNull());
+ QCOMPARE(latin1.isEmpty(), unicodesrc.isEmpty());
+ QCOMPARE(latin1.length(), unicodesrc.length());
+ QCOMPARE(latin1.isNull(), unicodedst.isNull());
+ QCOMPARE(latin1.isEmpty(), unicodedst.isEmpty());
+ QCOMPARE(latin1.length(), unicodedst.length());
if (!latin1.isEmpty())
while (latin1.length() < 128) {
diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp
index 41cabe8..c6da79a 100644
--- a/tests/auto/qtableview/tst_qtableview.cpp
+++ b/tests/auto/qtableview/tst_qtableview.cpp
@@ -3028,7 +3028,7 @@ void tst_QTableView::spans_data()
<< 1
<< 2;
- QTest::newRow("QTBUG-6004: No failing Q_ASSERT, then it passes.")
+ QTest::newRow("QTBUG-6004: No failing assertion, then it passes.")
<< 5 << 5
<< (SpanList() << QRect(0, 0, 2, 2) << QRect(0, 0, 1, 1))
<< false
@@ -3036,7 +3036,7 @@ void tst_QTableView::spans_data()
<< 1
<< 1;
- QTest::newRow("QTBUG-6004 (follow-up): No failing Q_ASSERT, then it passes.")
+ QTest::newRow("QTBUG-6004 (follow-up): No failing assertion, then it passes.")
<< 10 << 10
<< (SpanList() << QRect(2, 2, 1, 3) << QRect(2, 2, 1, 1))
<< false
diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
index 48bed85..1c33107 100644
--- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
@@ -166,7 +166,9 @@ private slots:
void readLineString();
void readChunks();
void waitForBytesWritten();
+ void waitForBytesWrittenMinusOne();
void waitForReadyRead();
+ void waitForReadyReadMinusOne();
void flush();
void synchronousApi();
void dontCloseOnTimeout();
@@ -1417,10 +1419,10 @@ void tst_QTcpSocket::readChunks()
void tst_QTcpSocket::waitForBytesWritten()
{
QTcpSocket *socket = newSocket();
- socket->connectToHost(QtNetworkSettings::serverName(), 22);
+ socket->connectToHost(QtNetworkSettings::serverName(), 80);
QVERIFY(socket->waitForConnected(10000));
- socket->write(QByteArray(10000, '@'));
+ socket->write("GET / HTTP/1.0\r\n\r\n");
qint64 toWrite = socket->bytesToWrite();
QVERIFY(socket->waitForBytesWritten(5000));
QVERIFY(toWrite > socket->bytesToWrite());
@@ -1429,11 +1431,37 @@ void tst_QTcpSocket::waitForBytesWritten()
}
//----------------------------------------------------------------------------------
+void tst_QTcpSocket::waitForBytesWrittenMinusOne()
+{
+ QTcpSocket *socket = newSocket();
+ socket->connectToHost(QtNetworkSettings::serverName(), 80);
+ QVERIFY(socket->waitForConnected(10000));
+
+ socket->write("GET / HTTP/1.0\r\n\r\n");
+ qint64 toWrite = socket->bytesToWrite();
+ QVERIFY(socket->waitForBytesWritten(-1));
+ QVERIFY(toWrite > socket->bytesToWrite());
+
+ delete socket;
+}
+
+//----------------------------------------------------------------------------------
void tst_QTcpSocket::waitForReadyRead()
{
QTcpSocket *socket = newSocket();
- socket->connectToHost(QtNetworkSettings::serverName(), 22);
- socket->waitForReadyRead(0);
+ socket->connectToHost(QtNetworkSettings::serverName(), 80);
+ socket->write("GET / HTTP/1.0\r\n\r\n");
+ QVERIFY(socket->waitForReadyRead(5000));
+ delete socket;
+}
+
+//----------------------------------------------------------------------------------
+void tst_QTcpSocket::waitForReadyReadMinusOne()
+{
+ QTcpSocket *socket = newSocket();
+ socket->connectToHost(QtNetworkSettings::serverName(), 80);
+ socket->write("GET / HTTP/1.0\r\n\r\n");
+ QVERIFY(socket->waitForReadyRead(-1));
delete socket;
}
diff --git a/tests/auto/qtessellator/dataparser.cpp b/tests/auto/qtessellator/dataparser.cpp
index 772f925..8ad7ae8 100644
--- a/tests/auto/qtessellator/dataparser.cpp
+++ b/tests/auto/qtessellator/dataparser.cpp
@@ -98,8 +98,12 @@ static QList<QPointF> parsePoints(const QByteArray &line)
QList<qreal> nums = parseNumbersList(it);
QList<qreal>::const_iterator nitr;
for (nitr = nums.begin(); nitr != nums.end(); ++nitr) {
- qreal x = *nitr; ++nitr;
- Q_ASSERT(nitr != nums.end());
+ qreal x = *nitr;
+ ++nitr;
+ if (nitr == nums.end()) {
+ qWarning() << "parsePoints: Even number of co-ordinates required, odd number found: skipping last point";
+ break;
+ }
qreal y = *nitr;
res.append(QPointF(x, y));
}
diff --git a/tests/auto/qtessellator/oldtessellator.cpp b/tests/auto/qtessellator/oldtessellator.cpp
index 7a76900..fd39d20 100644
--- a/tests/auto/qtessellator/oldtessellator.cpp
+++ b/tests/auto/qtessellator/oldtessellator.cpp
@@ -80,19 +80,6 @@ struct QEdge {
horizontal = p1.y == p2.y;
}
- inline qreal xAt(const qreal &y) const
- {
- Q_ASSERT(p1.y != p2.y);
- XFixed yf = XDoubleToFixed(y);
-
- if (yf == p1.y)
- return XFixedToDouble(p1.x);
- else if (yf == p2.y)
- return XFixedToDouble(p2.x);
-
- return (!vertical) ? (((y - b)*im)) : pf1.x();
- }
-
QPointF pf1, pf2;
XPointFixed p1, p2;
qreal m;
@@ -218,7 +205,8 @@ void old_tesselate_polygon(QVector<XTrapezoid> *traps, const QPointF *pg, int pg
qreal ymax(INT_MIN/256);
//painter.begin(pg, pgSize);
- Q_ASSERT(pg[0] == pg[pgSize-1]);
+ if (pg[0] != pg[pgSize-1])
+ qWarning() << Q_FUNC_INFO << "Malformed polygon (first and last points must be identical)";
// generate edge table
// qDebug() << "POINTS:";
for (int x = 0; x < pgSize-1; ++x) {
@@ -383,7 +371,8 @@ void old_tesselate_polygon(QVector<XTrapezoid> *traps, const QPointF *pg, int pg
isects[i].edge = edge;
}
- Q_ASSERT(isects.size()%2 == 1);
+ if (isects.size()%2 != 1)
+ qFatal("%s: number of intersection points must be odd", Q_FUNC_INFO);
// sort intersection points
qSort(&isects[0], &isects[isects.size()-1], compareIntersections);
diff --git a/tests/auto/qtessellator/testtessellator.cpp b/tests/auto/qtessellator/testtessellator.cpp
index be003b6..c2af1ae 100644
--- a/tests/auto/qtessellator/testtessellator.cpp
+++ b/tests/auto/qtessellator/testtessellator.cpp
@@ -42,6 +42,7 @@
#include <private/qtessellator_p.h>
#include "math.h"
+#include <QtCore/QDebug>
class TestTessellator : public QTessellator
{
@@ -91,7 +92,8 @@ void test_tessellate_polygon_rect(QVector<XTrapezoid> *traps, const QPointF *poi
bool winding)
{
// 5 points per rect
- Q_ASSERT(nPoints % 5 == 0);
+ if (nPoints % 5 != 0)
+ qWarning() << Q_FUNC_INFO << "multiples of 5 points expected";
TestTessellator t;
t.traps = traps;
diff --git a/tests/auto/qtextblock/tst_qtextblock.cpp b/tests/auto/qtextblock/tst_qtextblock.cpp
index 6477c50..fe4f246 100644
--- a/tests/auto/qtextblock/tst_qtextblock.cpp
+++ b/tests/auto/qtextblock/tst_qtextblock.cpp
@@ -76,7 +76,6 @@ private slots:
void excludeParagraphSeparatorFragment();
void backwardsBlockIterator();
void previousBlock_qtbug18026();
- void removedBlock_qtbug18500();
private:
QTextDocument *doc;
@@ -182,16 +181,5 @@ void tst_QTextBlock::previousBlock_qtbug18026()
QVERIFY(last.isValid());
}
-void tst_QTextBlock::removedBlock_qtbug18500()
-{
- cursor.insertText("line 1\nline 2\nline 3 \nline 4\n");
- cursor.setPosition(7);
- QTextBlock block = cursor.block();
- cursor.setPosition(21, QTextCursor::KeepAnchor);
-
- cursor.removeSelectedText();
- QVERIFY(!block.isValid());
-}
-
QTEST_MAIN(tst_QTextBlock)
#include "tst_qtextblock.moc"
diff --git a/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
index 88b725b..3657556 100644
--- a/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
+++ b/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
@@ -123,14 +123,14 @@ void tst_QTextBoundaryFinder::graphemeBoundaries()
if (test.at(pos).unicode() == 0xf7)
breakPositions.append(strPos);
else
- Q_ASSERT(test.at(pos).unicode() == 0xd7);
+ QVERIFY(test.at(pos).unicode() == 0xd7);
++pos;
if (pos < test.length()) {
- Q_ASSERT(pos < test.length() - 4);
+ QVERIFY(pos < test.length() - 4);
QString hex = test.mid(pos, 4);
bool ok = true;
testString.append(QChar(hex.toInt(&ok, 16)));
- Q_ASSERT(ok);
+ QVERIFY(ok);
pos += 4;
}
++strPos;
@@ -176,14 +176,14 @@ void tst_QTextBoundaryFinder::wordBoundaries()
if (test.at(pos).unicode() == 0xf7)
breakPositions.append(strPos);
else
- Q_ASSERT(test.at(pos).unicode() == 0xd7);
+ QVERIFY(test.at(pos).unicode() == 0xd7);
++pos;
if (pos < test.length()) {
- Q_ASSERT(pos < test.length() - 4);
+ QVERIFY(pos < test.length() - 4);
QString hex = test.mid(pos, 4);
bool ok = true;
testString.append(QChar(hex.toInt(&ok, 16)));
- Q_ASSERT(ok);
+ QVERIFY(ok);
pos += 4;
}
++strPos;
@@ -228,14 +228,14 @@ void tst_QTextBoundaryFinder::sentenceBoundaries()
if (test.at(pos).unicode() == 0xf7)
breakPositions.append(strPos);
else
- Q_ASSERT(test.at(pos).unicode() == 0xd7);
+ QVERIFY(test.at(pos).unicode() == 0xd7);
++pos;
if (pos < test.length()) {
- Q_ASSERT(pos < test.length() - 4);
+ QVERIFY(pos < test.length() - 4);
QString hex = test.mid(pos, 4);
bool ok = true;
testString.append(QChar(hex.toInt(&ok, 16)));
- Q_ASSERT(ok);
+ QVERIFY(ok);
pos += 4;
}
++strPos;
diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp
index f8e3aec..a0bfac6 100644
--- a/tests/auto/qtextcodec/tst_qtextcodec.cpp
+++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp
@@ -428,7 +428,7 @@ void tst_QTextCodec::flagCodepointFFFF() const
QString input(ch);
QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
- Q_ASSERT(codec);
+ QVERIFY(codec);
const QByteArray asDecoded(codec->fromUnicode(input));
QCOMPARE(asDecoded, QByteArray("?"));
@@ -465,7 +465,7 @@ void tst_QTextCodec::flagF7808080() const
QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
- Q_ASSERT(codec);
+ QVERIFY(codec);
//QVERIFY(!codec->canEncode(QChar(0x1C0000)));
@@ -482,7 +482,7 @@ void tst_QTextCodec::flagEFBFBF() const
invalidInput[2] = char(0xBF);
const QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
- Q_ASSERT(codec);
+ QVERIFY(codec);
{
//QVERIFY(!codec->canEncode(QChar(0xFFFF)));
@@ -1627,7 +1627,7 @@ void tst_QTextCodec::utf8bom()
QFETCH(QString, result);
QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
- Q_ASSERT(codec);
+ QVERIFY(codec);
QCOMPARE(codec->toUnicode(data.constData(), data.length(), 0), result);
diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp
index 58a2e00..1129219 100644
--- a/tests/auto/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp
@@ -180,6 +180,8 @@ private slots:
void escape_data();
void escape();
+ void copiedFontSize();
+
private:
void backgroundImage_checkExpectedHtml(const QTextDocument &doc);
@@ -2734,5 +2736,29 @@ void tst_QTextDocument::escape()
QCOMPARE(Qt::escape(original), expected);
}
+void tst_QTextDocument::copiedFontSize()
+{
+ QTextDocument documentInput;
+ QTextDocument documentOutput;
+
+ QFont fontInput;
+ fontInput.setPixelSize(24);
+
+ QTextCursor cursorInput(&documentInput);
+ QTextCharFormat formatInput = cursorInput.charFormat();
+ formatInput.setFont(fontInput);
+ cursorInput.insertText("Should be the same font", formatInput);
+ cursorInput.select(QTextCursor::Document);
+
+ QTextDocumentFragment fragmentInput(cursorInput);
+ QString html = fragmentInput.toHtml();
+
+ QTextCursor cursorOutput(&documentOutput);
+ QTextDocumentFragment fragmentOutput = QTextDocumentFragment::fromHtml(html);
+ cursorOutput.insertFragment(fragmentOutput);
+
+ QCOMPARE(cursorOutput.charFormat().font().pixelSize(), 24);
+}
+
QTEST_MAIN(tst_QTextDocument)
#include "tst_qtextdocument.moc"
diff --git a/tests/auto/qtextedit/tst_qtextedit.cpp b/tests/auto/qtextedit/tst_qtextedit.cpp
index 6747ecb..42ea3b1 100644
--- a/tests/auto/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/qtextedit/tst_qtextedit.cpp
@@ -317,7 +317,7 @@ void tst_QTextEdit::getSetCheck()
// void QTextEdit::setFontPointSize(qreal)
obj1.setFontPointSize(qreal(1.1));
QCOMPARE(qreal(1.1), obj1.fontPointSize());
- // we currently Q_ASSERT_X in QFont::setPointSizeF for that
+ // we currently assert in QFont::setPointSizeF for that
//obj1.setFontPointSize(0.0);
//QCOMPARE(1.1, obj1.fontPointSize()); // Should not accept 0.0 => keep old
@@ -327,7 +327,7 @@ void tst_QTextEdit::getSetCheck()
QCOMPARE(1, obj1.fontWeight()); // Range<1, 99>
obj1.setFontWeight(99);
QCOMPARE(99, obj1.fontWeight()); // Range<1, 99>
- /* Q_ASSERT_X in qfont.cpp
+ /* assertion in qfont.cpp
obj1.setFontWeight(INT_MIN);
QCOMPARE(1, obj1.fontWeight()); // Range<1, 99>
obj1.setFontWeight(INT_MAX);
@@ -2064,7 +2064,7 @@ void tst_QTextEdit::compareWidgetAndImage(QTextEdit &widget, const QString &imag
QCOMPARE(original.isNull(), false);
QCOMPARE(original.size(), image.size());
- Q_ASSERT(image.depth() == 32);
+ QCOMPARE(image.depth(), 32);
QCOMPARE(original.depth(), image.depth());
const int bytesPerLine = image.bytesPerLine();
@@ -2292,7 +2292,7 @@ void tst_QTextEdit::bidiVisualMovement()
option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft);
ed->document()->setDefaultTextOption(option);
- ed->document()->setDefaultCursorMoveStyle(QTextCursor::Visual);
+ ed->document()->setDefaultCursorMoveStyle(Qt::VisualMoveStyle);
ed->moveCursor(QTextCursor::Start);
ed->show();
@@ -2346,7 +2346,7 @@ void tst_QTextEdit::bidiLogicalMovement()
option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft);
ed->document()->setDefaultTextOption(option);
- ed->document()->setDefaultCursorMoveStyle(QTextCursor::Logical);
+ ed->document()->setDefaultCursorMoveStyle(Qt::LogicalMoveStyle);
ed->moveCursor(QTextCursor::Start);
ed->show();
diff --git a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp
index 0dbcf65..765afce 100644
--- a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp
+++ b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp
@@ -114,11 +114,14 @@ QString tst_QTextOdfWriter::getContentFromXml()
xmlWriter->writeEndDocument();
buffer->close();
QString stringContent = QString::fromUtf8(buffer->data());
+ QString ret;
int index = stringContent.indexOf("<dummy");
- Q_ASSERT(index);
- index = stringContent.indexOf('>', index);
- stringContent = stringContent.mid(index+1, stringContent.length() - index - 10);
- return stringContent;
+ if (index > 0) {
+ index = stringContent.indexOf('>', index);
+ if (index > 0)
+ ret = stringContent.mid(index+1, stringContent.length() - index - 10);
+ }
+ return ret;
}
void tst_QTextOdfWriter::testWriteParagraph_data()
diff --git a/tests/auto/qthread/tst_qthread.cpp b/tests/auto/qthread/tst_qthread.cpp
index 5a8543f..3c46212 100644
--- a/tests/auto/qthread/tst_qthread.cpp
+++ b/tests/auto/qthread/tst_qthread.cpp
@@ -209,7 +209,7 @@ public:
cond.wait(&mutex, five_minutes);
}
setTerminationEnabled(true);
- Q_ASSERT_X(false, "tst_QThread", "test case hung");
+ qFatal("tst_QThread: test case hung");
}
};
diff --git a/tests/auto/qtipc/qsharedmemory/src/qsystemlock_unix.cpp b/tests/auto/qtipc/qsharedmemory/src/qsystemlock_unix.cpp
index 14ad64e..9843796 100644
--- a/tests/auto/qtipc/qsharedmemory/src/qsystemlock_unix.cpp
+++ b/tests/auto/qtipc/qsharedmemory/src/qsystemlock_unix.cpp
@@ -207,7 +207,8 @@ bool QSystemLockPrivate::modifySemaphore(QSystemLockPrivate::Operation op,
if ((lockCount == 0 && op == Lock) || (lockCount > 0 && op == Unlock)) {
if (op == Unlock) {
--lockCount;
- Q_ASSERT(lockCount >= 0);
+ if (lockCount < 0)
+ qFatal("%s: lockCount must not be negative", Q_FUNC_INFO);
if (lockCount > 0)
return true;
}
diff --git a/tests/auto/qtipc/qsharedmemory/src/qsystemlock_win.cpp b/tests/auto/qtipc/qsharedmemory/src/qsystemlock_win.cpp
index 3e48bb5..c04b596 100644
--- a/tests/auto/qtipc/qsharedmemory/src/qsystemlock_win.cpp
+++ b/tests/auto/qtipc/qsharedmemory/src/qsystemlock_win.cpp
@@ -157,7 +157,8 @@ bool QSystemLockPrivate::modifySemaphore(QSystemLockPrivate::Operation op,
if ((lockCount == 0 && op == Lock) || (lockCount > 0 && op == Unlock)) {
if (op == Unlock) {
--lockCount;
- Q_ASSERT(lockCount >= 0);
+ if (lockCount < 0)
+ qFatal("%s: lockCount must not be negative", Q_FUNC_INFO);
if (lockCount > 0)
return true;
}
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index c9410b8..b902370 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -277,7 +277,8 @@ public:
}
int rowCount(const QModelIndex& parent = QModelIndex()) const {
- Q_ASSERT(fetched);
+ if (!fetched)
+ qFatal("%s: rowCount should not be called before fetching", Q_FUNC_INFO);
if ((parent.column() > 0) || (level(parent) > levels))
return 0;
return rows;
@@ -2536,7 +2537,7 @@ void tst_QTreeView::sortByColumn()
/*
This is a model that every time kill() is called it will completely change
- all of its nodes for new nodes. It then asserts if you later use a dead node.
+ all of its nodes for new nodes. It then qFatal's if you later use a dead node.
*/
class EvilModel: public QAbstractItemModel
{
@@ -2567,7 +2568,8 @@ public:
}
}
if (parent == 0) {
- Q_ASSERT(children.isEmpty());
+ if (!children.isEmpty())
+ qFatal("%s: children should be empty when parent is null", Q_FUNC_INFO);
populate();
} else {
isDead = true;
@@ -2624,7 +2626,8 @@ public:
Node *parentNode = root;
if (parent.isValid()) {
parentNode = static_cast<Node*>(parent.internalPointer());
- Q_ASSERT(!parentNode->isDead);
+ if (parentNode->isDead)
+ qFatal("%s: parentNode is dead!", Q_FUNC_INFO);
}
return parentNode->children.count();
}
@@ -2639,9 +2642,11 @@ public:
Node *grandparentNode = static_cast<Node*>(parent.internalPointer());
Node *parentNode = root;
if (parent.isValid()) {
- Q_ASSERT(!grandparentNode->isDead);
+ if (grandparentNode->isDead)
+ qFatal("%s: grandparentNode is dead!", Q_FUNC_INFO);
parentNode = grandparentNode->children[parent.row()];
- Q_ASSERT(!parentNode->isDead);
+ if (parentNode->isDead)
+ qFatal("%s: grandparentNode is dead!", Q_FUNC_INFO);
}
return createIndex(row, column, parentNode);
}
@@ -2661,7 +2666,8 @@ public:
Node *parentNode = root;
if (idx.isValid()) {
parentNode = static_cast<Node*>(idx.internalPointer());
- Q_ASSERT(!parentNode->isDead);
+ if (parentNode->isDead)
+ qFatal("%s: grandparentNode is dead!", Q_FUNC_INFO);
}
return QString("[%1,%2,%3]").arg(idx.row()).arg(idx.column())
.arg(parentNode->isDead ? "dead" : "alive");
diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp
index 7c3aafc..d7e9800 100644
--- a/tests/auto/qvariant/tst_qvariant.cpp
+++ b/tests/auto/qvariant/tst_qvariant.cpp
@@ -2650,7 +2650,6 @@ void tst_QVariant::invalidAsByteArray()
void tst_QVariant::invalidQColor() const
{
QVariant va("An invalid QColor::name() value.");
- QTest::ignoreMessage(QtWarningMsg, "QColor::setNamedColor: Unknown color name 'An invalid QColor::name() value.'");
QVERIFY(va.canConvert(QVariant::Color));
QVERIFY(!va.convert(QVariant::Color));
@@ -3240,18 +3239,24 @@ struct MyData
{
void *ptr;
MyData() : ptr(this) {}
- ~MyData() { Q_ASSERT(ptr == this); }
- MyData(const MyData& o) : ptr(this) { Q_ASSERT(o.ptr == &o); }
+ ~MyData()
+ {
+ if (ptr != this) qWarning("%s: object has moved", Q_FUNC_INFO);
+ }
+ MyData(const MyData& o) : ptr(this)
+ {
+ if (o.ptr != &o) qWarning("%s: other object has moved", Q_FUNC_INFO);
+ }
MyData &operator=(const MyData &o)
{
- Q_ASSERT(ptr == this);
- Q_ASSERT(o.ptr == &o);
+ if (ptr != this) qWarning("%s: object has moved", Q_FUNC_INFO);
+ if (o.ptr != &o) qWarning("%s: other object has moved", Q_FUNC_INFO);
return *this;
}
bool operator==(const MyData &o) const
{
- Q_ASSERT(ptr == this);
- Q_ASSERT(o.ptr == &o);
+ if (ptr != this) qWarning("%s: object has moved", Q_FUNC_INFO);
+ if (o.ptr != &o) qWarning("%s: other object has moved", Q_FUNC_INFO);
return true;
}
};
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index f54bac6..5550fe8 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -345,6 +345,7 @@ private slots:
void immediateRepaintAfterInvalidateBuffer();
#endif
void effectiveWinId();
+ void effectiveWinId2();
void customDpi();
void customDpiProperty();
@@ -4738,7 +4739,8 @@ void tst_QWidget::update()
QCOMPARE(w.visibleRegion(), expectedVisible);
QCOMPARE(w.paintedRegion, expectedVisible);
#ifdef QT_MAC_USE_COCOA
- QEXPECT_FAIL(0, "Cocoa compositor says to paint this.", Continue);
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
+ QEXPECT_FAIL(0, "Cocoa compositor says to paint this.", Continue);
#endif
QCOMPARE(child.numPaintEvents, 0);
@@ -6336,11 +6338,15 @@ void tst_QWidget::compatibilityChildInsertedEvents()
expected =
EventRecorder::EventList()
<< qMakePair(&widget, QEvent::PolishRequest)
- << qMakePair(&widget, QEvent::Type(QEvent::User + 1))
-#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) || defined(Q_WS_QPA)
- << qMakePair(&widget, QEvent::UpdateRequest)
-#endif
- ;
+ << qMakePair(&widget, QEvent::Type(QEvent::User + 1));
+
+#ifndef QT_MAC_USE_CARBON
+#ifdef QT_MAC_USE_COCOA
+ if (QApplicationPrivate::graphics_system_name == QLatin1String("raster"))
+#endif // QT_MAC_USE_COCOA
+ expected << qMakePair(&widget, QEvent::UpdateRequest);
+#endif // !QT_MAC_USE_CARBON
+
QCOMPARE(spy.eventList(), expected);
}
@@ -6432,11 +6438,15 @@ void tst_QWidget::compatibilityChildInsertedEvents()
#endif
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
- << qMakePair(&widget, QEvent::Type(QEvent::User + 2))
-#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) || defined(Q_WS_QPA)
- << qMakePair(&widget, QEvent::UpdateRequest)
-#endif
- ;
+ << qMakePair(&widget, QEvent::Type(QEvent::User + 2));
+
+#ifndef QT_MAC_USE_CARBON
+#ifdef QT_MAC_USE_COCOA
+ if (QApplicationPrivate::graphics_system_name == QLatin1String("raster"))
+#endif // QT_MAC_USE_COCOA
+ expected << qMakePair(&widget, QEvent::UpdateRequest);
+#endif // !QT_MAC_USE_CARBON
+
QCOMPARE(spy.eventList(), expected);
}
@@ -6528,11 +6538,15 @@ void tst_QWidget::compatibilityChildInsertedEvents()
#endif
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
- << qMakePair(&widget, QEvent::Type(QEvent::User + 2))
-#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) || defined(Q_WS_QPA)
- << qMakePair(&widget, QEvent::UpdateRequest)
-#endif
- ;
+ << qMakePair(&widget, QEvent::Type(QEvent::User + 2));
+
+#ifndef QT_MAC_USE_CARBON
+#ifdef QT_MAC_USE_COCOA
+ if (QApplicationPrivate::graphics_system_name == QLatin1String("raster"))
+#endif // QT_MAC_USE_COCOA
+ expected << qMakePair(&widget, QEvent::UpdateRequest);
+#endif // !QT_MAC_USE_CARBON
+
QCOMPARE(spy.eventList(), expected);
}
}
@@ -7220,8 +7234,7 @@ void tst_QWidget::render_systemClip2()
QFETCH(bool, usePaintEvent);
QFETCH(QColor, expectedColor);
- Q_ASSERT_X(expectedColor != QColor(Qt::red), Q_FUNC_INFO,
- "Qt::red is the reference color for the image, pick another color");
+ QVERIFY2(expectedColor != QColor(Qt::red), "Qt::red is the reference color for the image, pick another color");
class MyWidget : public QWidget
{
@@ -8482,6 +8495,30 @@ void tst_QWidget::effectiveWinId()
QVERIFY(child.effectiveWinId());
}
+void tst_QWidget::effectiveWinId2()
+{
+ QWidget parent;
+
+ class MyWidget : public QWidget {
+ bool event(QEvent *e)
+ {
+ if (e->type() == QEvent::WinIdChange) {
+ // Shouldn't crash.
+ effectiveWinId();
+ }
+
+ return QWidget::event(e);
+ }
+ };
+
+ MyWidget child;
+ child.setParent(&parent);
+ parent.show();
+
+ child.setParent(0);
+ child.setParent(&parent);
+}
+
class CustomWidget : public QWidget
{
public:
@@ -10384,7 +10421,7 @@ void tst_QWidget::taskQTBUG_7532_tabOrderWithFocusProxy()
w.setFocusProxy(fp);
QWidget::setTabOrder(&w, fp);
- // No Q_ASSERT, then it's allright.
+ // In debug mode, no assertion failure means it's alright.
}
void tst_QWidget::movedAndResizedAttributes()
diff --git a/tests/auto/qwizard/tst_qwizard.cpp b/tests/auto/qwizard/tst_qwizard.cpp
index 81eb2c5..b2656db 100644
--- a/tests/auto/qwizard/tst_qwizard.cpp
+++ b/tests/auto/qwizard/tst_qwizard.cpp
@@ -854,25 +854,26 @@ struct MyPage2 : public QWizardPage
public:
MyPage2() : init(0), cleanup(0), validate(0) {}
- void initializePage() { ++init; QWizardPage::initializePage(); checkInvariant(); }
- void cleanupPage() { ++cleanup; QWizardPage::cleanupPage(); checkInvariant(); }
+ void initializePage() { ++init; QWizardPage::initializePage(); }
+ void cleanupPage() { ++cleanup; QWizardPage::cleanupPage(); }
bool validatePage() { ++validate; return QWizardPage::validatePage(); }
- void check(int init, int cleanup)
- { Q_ASSERT(init == this->init && cleanup == this->cleanup); Q_UNUSED(init); Q_UNUSED(cleanup); }
+ bool check(int init, int cleanup)
+ {
+ return init == this->init
+ && cleanup == this->cleanup
+ && (this->init == this->cleanup || this->init - 1 == this->cleanup);
+ }
int init;
int cleanup;
int validate;
-
-private:
- void checkInvariant() { Q_ASSERT(init == cleanup || init - 1 == cleanup); }
};
#define CHECK_PAGE_INIT(i0, c0, i1, c1, i2, c2) \
- page0->check((i0), (c0)); \
- page1->check((i1), (c1)); \
- page2->check((i2), (c2));
+ QVERIFY(page0->check((i0), (c0))); \
+ QVERIFY(page1->check((i1), (c1))); \
+ QVERIFY(page2->check((i2), (c2)));
void tst_QWizard::setOption_IndependentPages()
{
diff --git a/tests/auto/qxmlinputsource/tst_qxmlinputsource.cpp b/tests/auto/qxmlinputsource/tst_qxmlinputsource.cpp
index 4194568..9d31b34 100644
--- a/tests/auto/qxmlinputsource/tst_qxmlinputsource.cpp
+++ b/tests/auto/qxmlinputsource/tst_qxmlinputsource.cpp
@@ -181,9 +181,7 @@ private slots:
{
if(bodyLength == -1)
{
- Q_ASSERT_X(false, Q_FUNC_INFO,
- "No length was specified in the header.");
- return;
+ qFatal("No length was specified in the header.");
}
QDomDocument domDoc;
diff --git a/tests/auto/qxmlquery/MessageValidator.cpp b/tests/auto/qxmlquery/MessageValidator.cpp
index b37fba1..0a588f6 100644
--- a/tests/auto/qxmlquery/MessageValidator.cpp
+++ b/tests/auto/qxmlquery/MessageValidator.cpp
@@ -51,9 +51,8 @@ MessageValidator::MessageValidator() : m_success(false)
MessageValidator::~MessageValidator()
{
- Q_ASSERT_X(m_hasChecked,
- Q_FUNC_INFO,
- "You must call success().");
+ if (!m_hasChecked)
+ qFatal("%s: You must call success().", Q_FUNC_INFO);
}
void MessageValidator::handleMessage(QtMsgType type,
diff --git a/tests/auto/qxmlquery/NetworkOverrider.h b/tests/auto/qxmlquery/NetworkOverrider.h
index 3322054..c64e422 100644
--- a/tests/auto/qxmlquery/NetworkOverrider.h
+++ b/tests/auto/qxmlquery/NetworkOverrider.h
@@ -70,6 +70,7 @@ public:
virtual QNetworkReply *createRequest(Operation op,
const QNetworkRequest &req,
QIODevice *outgoingData);
+ bool isValid() const;
private:
const QUrl m_rewriteFrom;
@@ -77,11 +78,10 @@ private:
};
NetworkOverrider::NetworkOverrider(const QUrl &rewriteFrom,
- const QUrl &rewriteTo) : m_rewriteFrom(rewriteFrom)
- , m_rewriteTo(rewriteTo)
+ const QUrl &rewriteTo)
+ : m_rewriteFrom(rewriteFrom)
+ , m_rewriteTo(rewriteTo)
{
- Q_ASSERT(m_rewriteFrom.isValid());
- Q_ASSERT(m_rewriteTo.isValid());
}
QNetworkReply *NetworkOverrider::createRequest(Operation op,
@@ -95,4 +95,9 @@ QNetworkReply *NetworkOverrider::createRequest(Operation op,
return QNetworkAccessManager::createRequest(op, newReq, outgoingData);
}
+
+bool NetworkOverrider::isValid() const
+{
+ return m_rewriteFrom.isValid() && m_rewriteTo.isValid();
+}
#endif
diff --git a/tests/auto/qxmlquery/PushBaseliner.h b/tests/auto/qxmlquery/PushBaseliner.h
index 8d9753c..652d919 100644
--- a/tests/auto/qxmlquery/PushBaseliner.h
+++ b/tests/auto/qxmlquery/PushBaseliner.h
@@ -65,9 +65,9 @@ public:
const QXmlNamePool &namePool) : m_out(out)
, m_namePool(namePool)
{
- Q_ASSERT(m_out.codec());
}
+ bool isValid() const;
virtual void startElement(const QXmlName&);
virtual void endElement();
virtual void attribute(const QXmlName&, const QStringRef&);
@@ -86,6 +86,11 @@ private:
const QXmlNamePool m_namePool;
};
+bool PushBaseliner::isValid() const
+{
+ return m_out.codec();
+}
+
void PushBaseliner::startElement(const QXmlName &name)
{
m_out << "startElement(" << name.toClarkName(m_namePool) << ')'<< endl;
diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp
index 853679f..1d3a0bc 100644
--- a/tests/auto/qxmlquery/tst_qxmlquery.cpp
+++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp
@@ -967,6 +967,7 @@ void tst_QXmlQuery::evaluateToReceiver()
QString produced;
QTextStream stream(&produced, QIODevice::WriteOnly);
PushBaseliner push(stream, query.namePool());
+ QVERIFY(push.isValid());
query.evaluateTo(&push);
const QString baselineName(inputFile(QLatin1String(SRCDIR "pushBaselines/") + inputQuery.left(inputQuery.length() - 2) + QString::fromLatin1("ref")));
@@ -1685,6 +1686,7 @@ void tst_QXmlQuery::constCorrectness() const
QString dummyString;
QTextStream dummyStream(&dummyString);
PushBaseliner dummy(dummyStream, query.namePool());
+ QVERIFY(dummy.isValid());
query.evaluateTo(&dummy);
}
}
@@ -3078,6 +3080,7 @@ void tst_QXmlQuery::setNetworkAccessManager() const
{
NetworkOverrider networkOverrider(QUrl(QLatin1String("tag:example.com:DOESNOTEXIST")),
QUrl(inputFileAsURI(QLatin1String(XMLPATTERNSDIR "/queries/simpleDocument.xml"))));
+ QVERIFY(networkOverrider.isValid());
QXmlQuery query;
query.setNetworkAccessManager(&networkOverrider);
@@ -3094,6 +3097,7 @@ void tst_QXmlQuery::setNetworkAccessManager() const
{
NetworkOverrider networkOverrider(QUrl(QLatin1String("tag:example.com:DOESNOTEXIST")),
QUrl(inputFileAsURI(QLatin1String(XMLPATTERNSDIR "/queries/concat.xq"))));
+ QVERIFY(networkOverrider.isValid());
QXmlQuery query;
query.setNetworkAccessManager(&networkOverrider);
diff --git a/tests/auto/qxmlsimplereader/tst_qxmlsimplereader.cpp b/tests/auto/qxmlsimplereader/tst_qxmlsimplereader.cpp
index 3a4e483..f2a973c 100644
--- a/tests/auto/qxmlsimplereader/tst_qxmlsimplereader.cpp
+++ b/tests/auto/qxmlsimplereader/tst_qxmlsimplereader.cpp
@@ -165,7 +165,7 @@ class tst_QXmlSimpleReader : public QObject
void roundtripWithNamespaces() const;
private:
- static QDomDocument fromByteArray(const QString &title, const QByteArray &ba);
+ static QDomDocument fromByteArray(const QString &title, const QByteArray &ba, bool *ok);
XmlServer *server;
};
@@ -730,25 +730,27 @@ void tst_QXmlSimpleReader::reportNamespace_data() const
<< QString("http://example.com/");
}
-QDomDocument tst_QXmlSimpleReader::fromByteArray(const QString &title, const QByteArray &ba)
+QDomDocument tst_QXmlSimpleReader::fromByteArray(const QString &title, const QByteArray &ba, bool *ok)
{
QDomDocument doc(title);
- const bool ret = doc.setContent(ba, true);
- Q_ASSERT(ret);
+ *ok = doc.setContent(ba, true);
return doc;
}
void tst_QXmlSimpleReader::roundtripWithNamespaces() const
{
- QEXPECT_FAIL("", "Known problem, see 154573. The fix happens to break uic.", Abort);
-
const char *const expected = "<element b:attr=\"value\" xmlns:a=\"http://www.example.com/A\" xmlns:b=\"http://www.example.com/B\" />\n";
+ bool ok;
{
const char *const xml = "<element xmlns:b=\"http://www.example.com/B\" b:attr=\"value\" xmlns:a=\"http://www.example.com/A\"/>";
- const QDomDocument one(fromByteArray("document", xml));
- const QDomDocument two(fromByteArray("document2", one.toByteArray(2)));
+ const QDomDocument one(fromByteArray("document", xml, &ok));
+ QVERIFY(ok);
+ const QDomDocument two(fromByteArray("document2", one.toByteArray(2), &ok));
+ QVERIFY(ok);
+
+ QEXPECT_FAIL("", "Known problem, see 154573. The fix happens to break uic.", Abort);
QCOMPARE(expected, one.toByteArray().constData());
QCOMPARE(one.toByteArray(2).constData(), two.toByteArray(2).constData());
@@ -758,8 +760,10 @@ void tst_QXmlSimpleReader::roundtripWithNamespaces() const
{
const char *const xml = "<element b:attr=\"value\" xmlns:b=\"http://www.example.com/B\" xmlns:a=\"http://www.example.com/A\"/>";
- const QDomDocument one(fromByteArray("document", xml));
- const QDomDocument two(fromByteArray("document2", one.toByteArray(2)));
+ const QDomDocument one(fromByteArray("document", xml, &ok));
+ QVERIFY(ok);
+ const QDomDocument two(fromByteArray("document2", one.toByteArray(2), &ok));
+ QVERIFY(ok);
QCOMPARE(expected, one.toByteArray().constData());
QCOMPARE(one.toByteArray(2).constData(), two.toByteArray(2).constData());
diff --git a/tests/auto/qxmlstream/qc14n.h b/tests/auto/qxmlstream/qc14n.h
index 7f3aa95..f7c17b5 100644
--- a/tests/auto/qxmlstream/qc14n.h
+++ b/tests/auto/qxmlstream/qc14n.h
@@ -47,17 +47,9 @@ QT_FORWARD_DECLARE_CLASS(QString)
class QC14N
{
public:
- enum Option
- {
- IgnoreProcessingInstruction,
- IgnoreComments
- };
- typedef QFlags<Option> Options;
-
static bool isEqual(QIODevice *const firstDocument,
QIODevice *const secondDocument,
- QString *const message = 0,
- const Options options = Options());
+ QString *const message = 0);
private:
static bool isDifferent(const QXmlStreamReader &r1,
@@ -76,20 +68,17 @@ private:
*/
bool QC14N::isEqual(QIODevice *const firstDocument,
QIODevice *const secondDocument,
- QString *const message,
- const Options options)
+ QString *const message)
{
qDebug() << Q_FUNC_INFO;
- Q_ASSERT_X(firstDocument, Q_FUNC_INFO,
- "A valid QIODevice pointer must be supplied");
- Q_ASSERT_X(secondDocument, Q_FUNC_INFO,
- "A valid QIODevice pointer must be supplied");
- Q_ASSERT_X(firstDocument->isReadable(), Q_FUNC_INFO, "The device must be readable.");
- Q_ASSERT_X(secondDocument->isReadable(), Q_FUNC_INFO, "The device must be readable.");
-
- Q_ASSERT_X(options == Options(), Q_FUNC_INFO,
- "Not yet implemented.");
- Q_UNUSED(options);
+ if (!firstDocument)
+ qFatal("%s: A valid firstDocument QIODevice pointer must be supplied", Q_FUNC_INFO);
+ if (!secondDocument)
+ qFatal("%s: A valid secondDocument QIODevice pointer must be supplied", Q_FUNC_INFO);
+ if (!firstDocument->isReadable())
+ qFatal("%s: The firstDocument device must be readable.", Q_FUNC_INFO);
+ if (!secondDocument->isReadable())
+ qFatal("%s: The secondDocument device must be readable.", Q_FUNC_INFO);
QXmlStreamReader r1(firstDocument);
QXmlStreamReader r2(secondDocument);
@@ -202,9 +191,9 @@ bool QC14N::isDifferent(const QXmlStreamReader &r1,
r2.processingInstructionData() == r2.processingInstructionData();
}
+ default:
+ qFatal("%s: Unknown tokenType: %d", Q_FUNC_INFO, static_cast<int>(r1.tokenType()));
+ return false;
}
-
- Q_ASSERT_X(false, Q_FUNC_INFO, "This line should never be reached");
- return false;
}
diff --git a/tests/auto/qxmlstream/tst_qxmlstream.cpp b/tests/auto/qxmlstream/tst_qxmlstream.cpp
index 426f050..0ddbe99 100644
--- a/tests/auto/qxmlstream/tst_qxmlstream.cpp
+++ b/tests/auto/qxmlstream/tst_qxmlstream.cpp
@@ -221,8 +221,7 @@ static QString documentElement(const QByteArray &document)
reader.readNext();
}
- Q_ASSERT_X(false, Q_FUNC_INFO,
- qPrintable(QString::fromLatin1("The input %1 didn't contain an element.").arg(QString::fromUtf8(document.constData()))));
+ qFatal("The input %s didn't contain an element", document.constData());
return QString();
}
@@ -265,7 +264,8 @@ public:
expected(aExpected),
output(aOutput)
{
- Q_ASSERT(!aId.isEmpty());
+ if (aId.isEmpty())
+ qFatal("%s: aId must not be an empty string", Q_FUNC_INFO);
}
QString id;
@@ -289,7 +289,8 @@ public:
TestSuiteHandler(const QUrl &baseURI) : runCount(0),
skipCount(0)
{
- Q_ASSERT(baseURI.isValid());
+ if (!baseURI.isValid())
+ qFatal("%s: baseURI must be valid", Q_FUNC_INFO);
m_baseURI.push(baseURI);
}
@@ -461,7 +462,7 @@ public:
}
else
{
- Q_ASSERT_X(false, Q_FUNC_INFO, "The input catalog is invalid.");
+ qFatal("The input catalog is invalid.");
return false;
}
}
@@ -481,9 +482,12 @@ public:
static bool isWellformed(QIODevice *const inputFile, const ParseMode mode)
{
- Q_ASSERT(inputFile);
- Q_ASSERT_X(inputFile->isOpen(), Q_FUNC_INFO, "The caller is responsible for opening the device.");
- Q_ASSERT(mode == ParseIncrementally || mode == ParseSinglePass);
+ if (!inputFile)
+ qFatal("%s: inputFile must be a valid QIODevice pointer", Q_FUNC_INFO);
+ if (!inputFile->isOpen())
+ qFatal("%s: inputFile must be opened by the caller", Q_FUNC_INFO);
+ if (mode != ParseIncrementally && mode != ParseSinglePass)
+ qFatal("%s: mode must be either ParseIncrementally or ParseSinglePass", Q_FUNC_INFO);
if(mode == ParseIncrementally)
{
diff --git a/tests/auto/selftests/alive/qtestalive.cpp b/tests/auto/selftests/alive/qtestalive.cpp
index 952058e..dd3d411 100644
--- a/tests/auto/selftests/alive/qtestalive.cpp
+++ b/tests/auto/selftests/alive/qtestalive.cpp
@@ -78,7 +78,8 @@ private:
QTestAlivePinger::QTestAlivePinger(QObject *receiver, QObject *parent)
: QObject(parent), rec(receiver), currentSequenceId(0), lastSequenceId(0)
{
- Q_ASSERT(rec);
+ if (!rec)
+ qFatal("Null receiver object passed to QTestAlivePinger::QTestAlivePinger()");
timerId = startTimer(850);
}
@@ -147,8 +148,8 @@ bool QTestAlive::event(QEvent *e)
void QTestAlive::run()
{
- Q_ASSERT_X(QCoreApplication::instance(), "QTestAlive::run()",
- "Cannot start QTestAlive without a QCoreApplication instance.");
+ if (!QCoreApplication::instance())
+ qFatal("QTestAlive::run(): Cannot start QTestAlive without a QCoreApplication instance.");
QTestAlivePinger p(this);
pinger = &p;
diff --git a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp
index 3485b8c..9f8de46 100644
--- a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp
+++ b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp
@@ -107,13 +107,13 @@ tst_XmlPatterns::tst_XmlPatterns() : m_generatedTests(0)
, m_dontRun(false)
{
Q_SET_DEFAULT_IAP
-
- Q_ASSERT(m_normalizeTestName.isValid());
- Q_ASSERT(m_filenameInStderr.isValid());
}
void tst_XmlPatterns::initTestCase()
{
+ QVERIFY(m_normalizeTestName.isValid());
+ QVERIFY(m_filenameInStderr.isValid());
+
QProcess process;
process.start(m_command);
@@ -121,7 +121,7 @@ void tst_XmlPatterns::initTestCase()
{
m_dontRun = true;
QEXPECT_FAIL("", "The command line tool is not in the path, most likely because Qt "
- "has been partically built, such as only the sub-src rule. No tests will be run.", Abort);
+ "has been partially built, such as only the sub-src rule. No tests will be run.", Abort);
QVERIFY(false);
}
diff --git a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp
index 553000e..76b7893 100644
--- a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp
+++ b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp
@@ -108,7 +108,7 @@ void tst_SuiteTest::runTestSuite() const
/* Run the tests, and serialize the result(as according to XQTSResult.xsd) to standard out. */
TestSuiteResult *const result = ts->runSuite();
- Q_ASSERT(result);
+ QVERIFY(result);
QFile out(m_candidateBaseline);
QVERIFY(out.open(QIODevice::WriteOnly));