Using Q_ASSERT does nothing in release-mode builds, and in debug builds
it causes tests to terminate prematurely. It is much better to use
QVERIFY or QCOMPARE.
Task-number: QTBUG-17582
Reviewed-by: Rohan McGovern
(cherry picked from commit
3475168550c1a804f04f2a4edfeb30c04cd36551)
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;
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;
QDeclarativeDebugConnection *m_conn;
QDeclarativeEngineDebug *m_dbg;
QDeclarativeEngine *m_engine;
{
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
waitForQuery(q_engines);
{
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);
if (q_engines->engines().count() == 0)
return QDeclarativeDebugObjectReference();
QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
for (int i=0; i<qml.count(); i++) {
QDeclarativeComponent component(m_engine);
component.setData(qml[i], QUrl::fromLocalFile(""));
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());
m_components << qobject_cast<QDeclarativeItem*>(component.create());
}
m_rootItem = qobject_cast<QDeclarativeItem*>(m_components.first());
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
bool ok = m_conn->waitForConnected();
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
bool ok = m_conn->waitForConnected();
QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
m_dbg = new QDeclarativeEngineDebug(m_conn, this);
QTRY_VERIFY(m_dbg->status() == QDeclarativeEngineDebug::Enabled);
QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
m_dbg = new QDeclarativeEngineDebug(m_conn, this);
QTRY_VERIFY(m_dbg->status() == QDeclarativeEngineDebug::Enabled);
QDeclarativeDebugPropertyReference prop = findProperty(obj.properties(), "width");
QDeclarativeDebugPropertyWatch *watch;
QDeclarativeDebugPropertyReference prop = findProperty(obj.properties(), "width");
QDeclarativeDebugPropertyWatch *watch;
QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
watch = unconnected->addWatch(prop, this);
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
watch = unconnected->addWatch(prop, this);
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
delete watch;
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());
watch = m_dbg->addWatch(prop, this);
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting);
QCOMPARE(watch->objectDebugId(), obj.debugId());
{
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
waitForQuery(q_engines);
{
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);
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);
QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this);
waitForQuery(q_obj);
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
delete watch;
delete unconnected;
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);
watch = m_dbg->addWatch(QDeclarativeDebugObjectReference(), this);
QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
QFETCH(int, incrementCount);
int origWidth = m_rootItem->property("width").toInt();
QFETCH(int, incrementCount);
int origWidth = m_rootItem->property("width").toInt();
QDeclarativeDebugObjectReference obj = findRootObject();
QDeclarativeDebugObjectExpressionWatch *watch;
QDeclarativeDebugObjectReference obj = findRootObject();
QDeclarativeDebugObjectExpressionWatch *watch;
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
delete watch;
delete unconnected;
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(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());
watch = m_dbg->addWatch(obj, expr, this);
QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting);
QCOMPARE(watch->objectDebugId(), obj.debugId());
delete watch;
// restore original value and verify spy doesn't get a signal since watch has been removed
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);
QTest::qWait(100);
QCOMPARE(spy.count(), expectedSpyCount);
delete q_engines;
QDeclarativeDebugRootContextQuery *q_context;
delete q_engines;
QDeclarativeDebugRootContextQuery *q_context;
QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
q_context = unconnected->queryRootContexts(engineId, this);
QCOMPARE(q_context->state(), QDeclarativeDebugQuery::Error);
QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
q_context = unconnected->queryRootContexts(engineId, this);
QCOMPARE(q_context->state(), QDeclarativeDebugQuery::Error);
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
waitForQuery(q_engines);
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];
QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
waitForQuery(q_context);
QDeclarativeDebugObjectReference rootObject = q_context->rootContext().objects()[0];
QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
waitForQuery(q_engines); // check immediate deletion is ok
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();
QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
waitForQuery(q_context);
int objectId = q_context->rootContext().objects()[0].debugId();
QCOMPARE(q_expr->state(), QDeclarativeDebugQuery::Error);
delete q_expr;
delete unconnected;
QCOMPARE(q_expr->state(), QDeclarativeDebugQuery::Error);
delete q_expr;
delete unconnected;
q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
delete q_expr;
q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
delete q_expr;
QDeclarativeDebugObjectQuery *query = m_dbg->queryObject(rootObject, this);
waitForQuery(query);
QDeclarativeDebugObjectReference obj = query->object();
QDeclarativeDebugObjectQuery *query = m_dbg->queryObject(rootObject, this);
waitForQuery(query);
QDeclarativeDebugObjectReference obj = query->object();
QDeclarativeDebugPropertyReference ref = findProperty(obj.properties(), "scale");
QVERIFY(ref.objectDebugId() > 0);
QDeclarativeDebugPropertyReference ref = findProperty(obj.properties(), "scale");
QVERIFY(ref.objectDebugId() > 0);
QVERIFY(!ref.valueTypeName().isEmpty());
QVERIFY(!ref.binding().isEmpty());
QVERIFY(ref.hasNotifySignal());
QVERIFY(!ref.valueTypeName().isEmpty());
QVERIFY(!ref.binding().isEmpty());
QVERIFY(ref.hasNotifySignal());
QDeclarativeDebugPropertyReference copy(ref);
QDeclarativeDebugPropertyReference copyAssign;
copyAssign = ref;
QDeclarativeDebugPropertyReference copy(ref);
QDeclarativeDebugPropertyReference copyAssign;
copyAssign = ref;
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
bool ok = m_conn->waitForConnected();
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
bool ok = m_conn->waitForConnected();
QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
QTRY_COMPARE(client.status(), QDeclarativeDebugClient::Enabled);
QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
QTRY_COMPARE(client.status(), QDeclarativeDebugClient::Enabled);
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
bool ok = m_conn->waitForConnected();
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
bool ok = m_conn->waitForConnected();
QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
}
QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
}
#endif
class tst_qdeclarativefontloader : public QObject
#endif
class tst_qdeclarativefontloader : public QObject
{
Q_OBJECT
public:
tst_qdeclarativefontloader();
private slots:
{
Q_OBJECT
public:
tst_qdeclarativefontloader();
private slots:
void noFont();
void namedFont();
void localFont();
void noFont();
void namedFont();
void localFont();
void failWebFont();
void changeFont();
void failWebFont();
void changeFont();
private:
QDeclarativeEngine engine;
TestHTTPServer server;
private:
QDeclarativeEngine engine;
TestHTTPServer server;
server(SERVER_PORT)
{
server.serveDirectory(SRCDIR "/data");
server(SERVER_PORT)
{
server.serveDirectory(SRCDIR "/data");
- Q_ASSERT(server.isValid());
+}
+
+void tst_qdeclarativefontloader::init()
+{
+ QVERIFY(server.isValid());
}
void tst_qdeclarativefontloader::noFont()
}
void tst_qdeclarativefontloader::noFont()