void tst_QDeclarativeDebug::initTestCase() { qRegisterMetaType<QDeclarativeDebugWatch::State>(); QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 3768..."); qputenv("QML_DEBUG_SERVER_PORT", "3768"); m_engine = new QDeclarativeEngine(this); QList<QByteArray> qml; qml << "import Qt 4.7\n" "Item {" "width: 10; height: 20; scale: blueRect.scale;" "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }" "Text { color: blueRect.color; }" "MouseArea {" "onEntered: { console.log('hello') }" "}" "}"; // add second component to test multiple root contexts qml << "import Qt 4.7\n" "Item {}"; // and a third to test methods qml << "import Qt 4.7\n" "Item {" "function myMethodNoArgs() { return 3; }\n" "function myMethod(a) { return a + 9; }\n" "function myMethodIndirect() { myMethod(3); }\n" "}"; 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 m_components << qobject_cast<QDeclarativeItem*>(component.create()); } m_rootItem = qobject_cast<QDeclarativeItem*>(m_components.first()); // add an extra context to test for multiple contexts QDeclarativeContext *context = new QDeclarativeContext(m_engine->rootContext(), this); context->setObjectName("tst_QDeclarativeDebug_childContext"); m_conn = new QDeclarativeDebugConnection(this); m_conn->connectToHost("127.0.0.1", 3768); QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established"); bool ok = m_conn->waitForConnected(); Q_ASSERT(ok); QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient()); m_dbg = new QDeclarativeEngineDebug(m_conn, this); }
void tst_QDeclarativeDebug::initTestCase() { qRegisterMetaType<QDeclarativeDebugWatch::State>(); qmlRegisterType<NonScriptProperty>("Test", 1, 0, "NonScriptPropertyElement"); QTest::ignoreMessage(QtDebugMsg, "QDeclarativeDebugServer: Waiting for connection on port 3768..."); m_engine = new QDeclarativeEngine(this); QList<QByteArray> qml; qml << "import QtQuick 1.0\n" "import Test 1.0\n" "Item {" "id: root\n" "width: 10; height: 20; scale: blueRect.scale;" "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }" "Text { color: blueRect.color; }" "MouseArea {" "onEntered: { console.log('hello') }" "}" "property variant varObj\n" "property variant varObjList: []\n" "Component.onCompleted: {\n" "varObj = blueRect;\n" "var list = varObjList;\n" "list[0] = blueRect;\n" "varObjList = list;\n" "}\n" "NonScriptPropertyElement {\n" "}\n" "}"; // add second component to test multiple root contexts qml << "import QtQuick 1.0\n" "Item {}"; // and a third to test methods qml << "import QtQuick 1.0\n" "Item {" "function myMethodNoArgs() { return 3; }\n" "function myMethod(a) { return a + 9; }\n" "function myMethodIndirect() { myMethod(3); }\n" "}"; // and a fourth to test states qml << "import QtQuick 1.0\n" "Rectangle {\n" "id:rootRect\n" "width:100\n" "states: [\n" "State {\n" "name:\"state1\"\n" "PropertyChanges {\n" "target:rootRect\n" "width:200\n" "}\n" "}\n" "]\n" "transitions: [\n" "Transition {\n" "from:\"*\"\n" "to:\"state1\"\n" "PropertyAnimation {\n" "target:rootRect\n" "property:\"width\"\n" "duration:100\n" "}\n" "}\n" "]\n" "}\n" ; for (int i=0; i<qml.count(); i++) { QDeclarativeComponent component(m_engine); component.setData(qml[i], QUrl::fromLocalFile("")); QVERIFY(component.isReady()); // fails if bad syntax m_components << qobject_cast<QDeclarativeItem*>(component.create()); } m_rootItem = qobject_cast<QDeclarativeItem*>(m_components.first()); // add an extra context to test for multiple contexts QDeclarativeContext *context = new QDeclarativeContext(m_engine->rootContext(), this); context->setObjectName("tst_QDeclarativeDebug_childContext"); m_conn = new QDeclarativeDebugConnection(this); m_conn->connectToHost("127.0.0.1", 3768); QTest::ignoreMessage(QtDebugMsg, "QDeclarativeDebugServer: Connection established"); bool ok = m_conn->waitForConnected(); QVERIFY(ok); QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient()); m_dbg = new QDeclarativeEngineDebug(m_conn, this); QTRY_VERIFY(m_dbg->status() == QDeclarativeEngineDebug::Enabled); }