From a8549cfee8b6ec393dcea6314e6ac7d6c102dc07 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 14:08:07 +1000 Subject: Webkit console.log() compatibility. This allows avoiding the more non-standard print(). --- src/declarative/qml/qmlengine.cpp | 27 ++++++++++++++++++++++++++- src/declarative/qml/qmlengine_p.h | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index e292e5c..0a00092 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -145,6 +145,12 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) qtObject.setProperty(QLatin1String("openUrlExternally"),scriptEngine.newFunction(desktopOpenUrl, 1)); qtObject.setProperty(QLatin1String("md5"),scriptEngine.newFunction(md5, 1)); + //firebug/webkit compat + QScriptValue consoleObject = scriptEngine.newObject(); + consoleObject.setProperty(QLatin1String("log"),scriptEngine.newFunction(consoleLog, 1)); + consoleObject.setProperty(QLatin1String("debug"),scriptEngine.newFunction(consoleLog, 1)); + scriptEngine.globalObject().setProperty(QLatin1String("console"), consoleObject); + scriptEngine.globalObject().setProperty(QLatin1String("createQmlObject"), scriptEngine.newFunction(QmlEnginePrivate::createQmlObject, 1)); scriptEngine.globalObject().setProperty(QLatin1String("createComponent"), @@ -800,7 +806,7 @@ QScriptValue QmlEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QScriptEngin return e->newVariant(QVariant(ret)); } -QScriptValue QmlEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *e) +QScriptValue QmlEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *) { QByteArray data; @@ -812,6 +818,25 @@ QScriptValue QmlEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *e) return QScriptValue(QLatin1String(result.toHex())); } +QScriptValue QmlEnginePrivate::consoleLog(QScriptContext *ctxt, QScriptEngine *e) +{ + if(ctxt->argumentCount() < 1) + return e->newVariant(QVariant(false)); + + QByteArray msg; + + for (int i=0; iargumentCount(); ++i) { + if (!msg.isEmpty()) msg += ' '; + msg += ctxt->argument(i).toString().toLocal8Bit(); + // does not support firebug "%[a-z]" formatting, since firebug really + // does just ignore the format letter, which makes it pointless. + } + + qDebug("%s",msg.data()); + + return e->newVariant(QVariant(true)); +} + QScriptValue QmlEnginePrivate::closestAngle(QScriptContext *ctxt, QScriptEngine *e) { if(ctxt->argumentCount() < 2) diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index 2f41651..c11a399 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -269,6 +269,7 @@ public: static QScriptValue playSound(QScriptContext*, QScriptEngine*); static QScriptValue desktopOpenUrl(QScriptContext*, QScriptEngine*); static QScriptValue md5(QScriptContext*, QScriptEngine*); + static QScriptValue consoleLog(QScriptContext*, QScriptEngine*); static QScriptEngine *getScriptEngine(QmlEngine *e) { return &e->d_func()->scriptEngine; } static QmlEngine *getEngine(QScriptEngine *e) { return static_cast(e)->p->q_func(); } -- cgit v0.12 From 3c4df26a8d184b728395c8aad26b05626176b7b5 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 14:26:49 +1000 Subject: Use console.log, not print. --- tests/auto/declarative/qmldebug/tst_qmldebug.cpp | 2 +- tests/auto/declarative/qmlecmascript/data/scriptErrors.qml | 2 +- tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp | 2 +- tests/auto/declarative/qmlgraphicslistview/data/listview.qml | 12 ++++++------ .../auto/declarative/qmlgraphicspathview/data/datamodel.qml | 2 +- tests/auto/declarative/qmlgraphicsrepeater/data/intmodel.qml | 2 +- tests/auto/declarative/qmlgraphicsrepeater/data/itemlist.qml | 2 +- tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp | 4 ++-- tests/auto/declarative/qmllanguage/data/OnCompletedType.qml | 2 +- .../qmllanguage/data/customParserIdNotAllowed.errors.txt | 2 +- tests/auto/declarative/qmllanguage/data/defaultGrouped.qml | 2 +- tests/auto/declarative/qmllanguage/data/doubleSignal.qml | 4 ++-- .../declarative/qmllanguage/data/dynamicSignalsAndSlots.qml | 2 +- .../qmllanguage/data/invalidGroupedProperty.7.qml | 2 +- tests/auto/declarative/qmllanguage/data/missingSignal.qml | 2 +- tests/auto/declarative/qmllanguage/data/onCompleted.qml | 4 ++-- tests/auto/declarative/qmllanguage/data/scriptString.qml | 2 +- tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp | 4 +++- .../auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp | 4 ++-- tests/auto/declarative/qmlqt/data/consoleLog.qml | 8 ++++++++ tests/auto/declarative/qmlqt/tst_qmlqt.cpp | 11 +++++++++++ tests/auto/declarative/valuetypes/data/deletedObject.js | 4 ++-- tests/auto/declarative/visual/focusscope/test.qml | 10 +++++----- tests/auto/declarative/visual/focusscope/test3.qml | 4 ++-- tests/auto/declarative/visual/webview/zooming/zooming.qml | 4 ++-- 25 files changed, 60 insertions(+), 39 deletions(-) create mode 100644 tests/auto/declarative/qmlqt/data/consoleLog.qml diff --git a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp index 6916cc9..785d55f 100644 --- a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp +++ b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp @@ -816,7 +816,7 @@ int main(int argc, char *argv[]) "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }" "Text { color: blueRect.color; }" "MouseRegion {" - "onEntered: { print('hello') }" + "onEntered: { console.log('hello') }" "}" "}"; // add second component to test multiple root contexts diff --git a/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml b/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml index ff22990..9d99b41 100644 --- a/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml +++ b/tests/auto/declarative/qmlecmascript/data/scriptErrors.qml @@ -9,7 +9,7 @@ MyQmlObject { property int x: undefinedObject property int y: (a.value, undefinedObject) - onBasicSignal: { print(a.value); } + onBasicSignal: { console.log(a.value); } } diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index 983ddd0..fe3ae6b 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -218,7 +218,7 @@ void tst_qmlecmascript::basicExpressions_data() QTest::addColumn("result"); QTest::addColumn("nest"); - QTest::newRow("Syntax error (self test)") << "{print({'a':1'}.a)}" << QVariant() << false; + QTest::newRow("Syntax error (self test)") << "{console.log({'a':1'}.a)}" << QVariant() << false; QTest::newRow("Context property") << "a" << QVariant(1944) << false; QTest::newRow("Context property") << "a" << QVariant(1944) << true; QTest::newRow("Context property expression") << "a * 2" << QVariant(3888) << false; diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml index b64b399..99b3db6 100644 --- a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml +++ b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml @@ -7,23 +7,23 @@ Rectangle { function checkProperties() { testObject.error = false; if (list.model != testModel) { - print("model property incorrect"); + console.log("model property incorrect"); testObject.error = true; } if (!testObject.animate && list.delegate != myDelegate) { - print("delegate property incorrect - expected myDelegate"); + console.log("delegate property incorrect - expected myDelegate"); testObject.error = true; } if (testObject.animate && list.delegate != animatedDelegate) { - print("delegate property incorrect - expected animatedDelegate"); + console.log("delegate property incorrect - expected animatedDelegate"); testObject.error = true; } if (testObject.invalidHighlight && list.highlight != invalidHl) { - print("highlight property incorrect - expected invalidHl"); + console.log("highlight property incorrect - expected invalidHl"); testObject.error = true; } if (!testObject.invalidHighlight && list.highlight != myHighlight) { - print("highlight property incorrect - expected myHighlight"); + console.log("highlight property incorrect - expected myHighlight"); testObject.error = true; } } @@ -85,7 +85,7 @@ Rectangle { } color: ListView.isCurrentItem ? "lightsteelblue" : "white" ListView.onRemove: SequentialAnimation { - ScriptAction { script: print("Fix PropertyAction with attached properties") } + ScriptAction { script: console.log("Fix PropertyAction with attached properties") } /* PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" } diff --git a/tests/auto/declarative/qmlgraphicspathview/data/datamodel.qml b/tests/auto/declarative/qmlgraphicspathview/data/datamodel.qml index 6aea96b..9d08e5d 100644 --- a/tests/auto/declarative/qmlgraphicspathview/data/datamodel.qml +++ b/tests/auto/declarative/qmlgraphicspathview/data/datamodel.qml @@ -9,7 +9,7 @@ PathView { function checkProperties() { testObject.error = false; if (testObject.useModel && view.model != itemModel) { - print("model property incorrect"); + console.log("model property incorrect"); testObject.error = true; } } diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/intmodel.qml b/tests/auto/declarative/qmlgraphicsrepeater/data/intmodel.qml index 2d6eae8..cf1fb4d 100644 --- a/tests/auto/declarative/qmlgraphicsrepeater/data/intmodel.qml +++ b/tests/auto/declarative/qmlgraphicsrepeater/data/intmodel.qml @@ -10,7 +10,7 @@ Rectangle { function checkProperties() { testObject.error = false; if (repeater.delegate != comp) { - print("delegate property incorrect"); + console.log("delegate property incorrect"); testObject.error = true; } } diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/itemlist.qml b/tests/auto/declarative/qmlgraphicsrepeater/data/itemlist.qml index 8d28bf8..fc6b34c 100644 --- a/tests/auto/declarative/qmlgraphicsrepeater/data/itemlist.qml +++ b/tests/auto/declarative/qmlgraphicsrepeater/data/itemlist.qml @@ -11,7 +11,7 @@ Rectangle { function checkProperties() { testObject.error = false; if (testObject.useModel && view.model != itemModel) { - print("model property incorrect"); + console.log("model property incorrect"); testObject.error = true; } } diff --git a/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp b/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp index f493e0e..1173f85 100644 --- a/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp +++ b/tests/auto/declarative/qmlinstruction/tst_qmlinstruction.cpp @@ -316,7 +316,7 @@ void tst_qmlinstruction::dump() } { - data->primitives << "print(1921)"; + data->primitives << "console.log(1921)"; QmlInstruction i; i.line = 27; @@ -564,7 +564,7 @@ void tst_qmlinstruction::dump() << "24\t\t24\tSTORE_OBJECT\t\t21" << "25\t\t25\tSTORE_VARIANT_OBJECT\t22" << "26\t\t26\tSTORE_INTERFACE\t\t23" - << "27\t\t27\tSTORE_SIGNAL\t\t2\t4\t\t\"print(1921)\"" + << "27\t\t27\tSTORE_SIGNAL\t\t2\t4\t\t\"console.log(1921)\"" << "28\t\t28\tSTORE_SCRIPT\t\t2\t18\t28" << "29\t\t29\tSTORE_SCRIPT_STRING\t24\t3\t1" << "30\t\t30\tASSIGN_SIGNAL_OBJECT\t0\t\t\t\"mySignal\"" diff --git a/tests/auto/declarative/qmllanguage/data/OnCompletedType.qml b/tests/auto/declarative/qmllanguage/data/OnCompletedType.qml index cdba495..2889caf 100644 --- a/tests/auto/declarative/qmllanguage/data/OnCompletedType.qml +++ b/tests/auto/declarative/qmllanguage/data/OnCompletedType.qml @@ -4,5 +4,5 @@ import Qt 4.6 MyQmlObject { property int a: Math.max(10, 9) property int b: 11 - Component.onCompleted: print("Completed " + a + " " + b); + Component.onCompleted: console.log("Completed " + a + " " + b); } diff --git a/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.errors.txt b/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.errors.txt index d28c0bd..43a8bb2 100644 --- a/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.errors.txt +++ b/tests/auto/declarative/qmllanguage/data/customParserIdNotAllowed.errors.txt @@ -1 +1 @@ -4:19:Cannot use reserved "id" property in ListModel +4:19:ListElement: cannot use reserved "id" property diff --git a/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml b/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml index 532b2bb..0fd1404 100644 --- a/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml +++ b/tests/auto/declarative/qmllanguage/data/defaultGrouped.qml @@ -3,7 +3,7 @@ import Qt 4.6 MyTypeObject { grouped { - script: print(1921) + script: console.log(1921) QtObject {} } } diff --git a/tests/auto/declarative/qmllanguage/data/doubleSignal.qml b/tests/auto/declarative/qmllanguage/data/doubleSignal.qml index ec813c9..fb07b9f 100644 --- a/tests/auto/declarative/qmllanguage/data/doubleSignal.qml +++ b/tests/auto/declarative/qmllanguage/data/doubleSignal.qml @@ -1,7 +1,7 @@ import Test 1.0 MyQmlObject { - onBasicSignal: print(1921) - onBasicSignal: print(1921) + onBasicSignal: console.log(1921) + onBasicSignal: console.log(1921) } diff --git a/tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml b/tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml index 737681e..2a834e8 100644 --- a/tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml +++ b/tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml @@ -6,5 +6,5 @@ QtObject { function slot2() {} property int test: 0 - function slot3(a) { print(1921); test = a; } + function slot3(a) { console.log(1921); test = a; } } diff --git a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.qml b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.qml index b77fb90..977539a 100644 --- a/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.qml +++ b/tests/auto/declarative/qmllanguage/data/invalidGroupedProperty.7.qml @@ -1,5 +1,5 @@ import Test 1.0 MyTypeObject { - nullGrouped.script: print(1921) + nullGrouped.script: console.log(1921) } diff --git a/tests/auto/declarative/qmllanguage/data/missingSignal.qml b/tests/auto/declarative/qmllanguage/data/missingSignal.qml index 8a87437..3bf75f6 100644 --- a/tests/auto/declarative/qmllanguage/data/missingSignal.qml +++ b/tests/auto/declarative/qmllanguage/data/missingSignal.qml @@ -1,5 +1,5 @@ import Test 1.0 import Qt 4.6 QtObject { - onClicked: print("Hello world!") + onClicked: console.log("Hello world!") } diff --git a/tests/auto/declarative/qmllanguage/data/onCompleted.qml b/tests/auto/declarative/qmllanguage/data/onCompleted.qml index ae47d4b..5725f85 100644 --- a/tests/auto/declarative/qmllanguage/data/onCompleted.qml +++ b/tests/auto/declarative/qmllanguage/data/onCompleted.qml @@ -5,13 +5,13 @@ MyTypeObject { // We set a and b to ensure that onCompleted is executed after bindings and // constants have been assigned property int a: Math.min(6, 7) - Component.onCompleted: print("Completed " + a + " " + nestedObject.b) + Component.onCompleted: console.log("Completed " + a + " " + nestedObject.b) objectProperty: OnCompletedType { qmlobjectProperty: MyQmlObject { id: nestedObject property int b: 10 - Component.onCompleted: print("Completed " + a + " " + nestedObject.b) + Component.onCompleted: console.log("Completed " + a + " " + nestedObject.b) } } } diff --git a/tests/auto/declarative/qmllanguage/data/scriptString.qml b/tests/auto/declarative/qmllanguage/data/scriptString.qml index 51e6e48..40a3bbe 100644 --- a/tests/auto/declarative/qmllanguage/data/scriptString.qml +++ b/tests/auto/declarative/qmllanguage/data/scriptString.qml @@ -2,5 +2,5 @@ import Test 1.0 MyTypeObject { scriptProperty: foo + bar - grouped.script: print(1921) + grouped.script: console.log(1921) } diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp index 892d2eb..685beaf 100644 --- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp +++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp @@ -606,6 +606,8 @@ void tst_qmllanguage::dynamicObjectProperties() // Tests the declaration of dynamic signals and slots void tst_qmllanguage::dynamicSignalsAndSlots() { + QTest::ignoreMessage(QtDebugMsg, "1921"); + QmlComponent component(&engine, TEST_FILE("dynamicSignalsAndSlots.qml")); VERIFY_ERRORS(0); QObject *object = component.create(); @@ -956,7 +958,7 @@ void tst_qmllanguage::scriptString() QCOMPARE(object->scriptProperty().context(), qmlContext(object)); QVERIFY(object->grouped() != 0); - QCOMPARE(object->grouped()->script().script(), QString("print(1921)")); + QCOMPARE(object->grouped()->script().script(), QString("console.log(1921)")); QCOMPARE(object->grouped()->script().scopeObject(), object); QCOMPARE(object->grouped()->script().context(), qmlContext(object)); } diff --git a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp index d6e88b5..8dcfc11 100644 --- a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp +++ b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp @@ -854,12 +854,12 @@ void tst_qmlmetaproperty::write() { PropertyObject o; QmlMetaProperty p(&o, "onClicked"); - QCOMPARE(p.write(QVariant("print(1921)")), false); + QCOMPARE(p.write(QVariant("console.log(1921)")), false); QVERIFY(0 == p.setSignalExpression(new QmlExpression())); QVERIFY(0 != p.signalExpression()); - QCOMPARE(p.write(QVariant("print(1921)")), false); + QCOMPARE(p.write(QVariant("console.log(1921)")), false); QVERIFY(0 != p.signalExpression()); } diff --git a/tests/auto/declarative/qmlqt/data/consoleLog.qml b/tests/auto/declarative/qmlqt/data/consoleLog.qml new file mode 100644 index 0000000..e657ff1 --- /dev/null +++ b/tests/auto/declarative/qmlqt/data/consoleLog.qml @@ -0,0 +1,8 @@ +import Qt 4.6 + +QtObject { + Component.onCompleted: { + console.log("completed", "ok") + console.log("completed ok") + } +} diff --git a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp index 292102a..21c5478 100644 --- a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp +++ b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp @@ -72,6 +72,7 @@ private slots: void md5(); void createComponent(); void createQmlObject(); + void consoleLog(); private: QmlEngine engine; @@ -353,6 +354,16 @@ void tst_qmlqt::createQmlObject() delete object; } +void tst_qmlqt::consoleLog() +{ + QTest::ignoreMessage(QtDebugMsg, "completed ok"); + QTest::ignoreMessage(QtDebugMsg, "completed ok"); + QmlComponent component(&engine, TEST_FILE("consoleLog.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; +} + QTEST_MAIN(tst_qmlqt) #include "tst_qmlqt.moc" diff --git a/tests/auto/declarative/valuetypes/data/deletedObject.js b/tests/auto/declarative/valuetypes/data/deletedObject.js index f554a0f..af298ff 100644 --- a/tests/auto/declarative/valuetypes/data/deletedObject.js +++ b/tests/auto/declarative/valuetypes/data/deletedObject.js @@ -3,11 +3,11 @@ var savedReference; function startup() { savedReference = object.rect; - print("Test: " + savedReference.x); + console.log("Test: " + savedReference.x); } function afterDelete() { - print("Test: " + savedReference.x); + console.log("Test: " + savedReference.x); } diff --git a/tests/auto/declarative/visual/focusscope/test.qml b/tests/auto/declarative/visual/focusscope/test.qml index 77ffb84..dd6d726 100644 --- a/tests/auto/declarative/visual/focusscope/test.qml +++ b/tests/auto/declarative/visual/focusscope/test.qml @@ -5,13 +5,13 @@ Rectangle { width: 800 height: 600 - Keys.onDigit9Pressed: print("Error - Root") + Keys.onDigit9Pressed: console.log("Error - Root") FocusScope { id: MyScope focus: true - Keys.onDigit9Pressed: print("Error - FocusScope") + Keys.onDigit9Pressed: console.log("Error - FocusScope") Rectangle { height: 120 @@ -27,7 +27,7 @@ Rectangle { width: 100; height: 100; color: "green" border.width: 5 border.color: wantsFocus?"blue":"black" - Keys.onDigit9Pressed: print("Top Left"); + Keys.onDigit9Pressed: console.log("Top Left"); KeyNavigation.right: Item2 focus: true @@ -44,7 +44,7 @@ Rectangle { border.width: 5 border.color: wantsFocus?"blue":"black" KeyNavigation.left: Item1 - Keys.onDigit9Pressed: print("Top Right"); + Keys.onDigit9Pressed: console.log("Top Right"); Rectangle { width: 50; height: 50; anchors.centerIn: parent @@ -64,7 +64,7 @@ Rectangle { border.width: 5 border.color: wantsFocus?"blue":"black" - Keys.onDigit9Pressed: print("Bottom Left"); + Keys.onDigit9Pressed: console.log("Bottom Left"); KeyNavigation.up: MyScope Rectangle { diff --git a/tests/auto/declarative/visual/focusscope/test3.qml b/tests/auto/declarative/visual/focusscope/test3.qml index b5feeb5..4be9dc7 100644 --- a/tests/auto/declarative/visual/focusscope/test3.qml +++ b/tests/auto/declarative/visual/focusscope/test3.qml @@ -23,10 +23,10 @@ Rectangle { FocusScope { id: Root width: 50; height: 50; - Keys.onDigit9Pressed: print("Error - " + name) + Keys.onDigit9Pressed: console.log("Error - " + name) Rectangle { focus: true - Keys.onDigit9Pressed: print(name) + Keys.onDigit9Pressed: console.log(name) width: 50; height: 50; color: Root.ListView.isCurrentItem?"red":"green" Text { text: name; anchors.centerIn: parent } diff --git a/tests/auto/declarative/visual/webview/zooming/zooming.qml b/tests/auto/declarative/visual/webview/zooming/zooming.qml index 3ac57f6..0ea9131 100644 --- a/tests/auto/declarative/visual/webview/zooming/zooming.qml +++ b/tests/auto/declarative/visual/webview/zooming/zooming.qml @@ -12,6 +12,6 @@ WebView { url: "zooming.html" preferredWidth: width preferredHeight: height - onDoubleClick: {print(clickX,clickY);heuristicZoom(clickX,clickY,2)} - onZoomTo: {print(zoom);scale=zoom;x=width/2-centerX;y=height/2-centerY} + onDoubleClick: {console.log(clickX,clickY);heuristicZoom(clickX,clickY,2)} + onZoomTo: {console.log(zoom);scale=zoom;x=width/2-centerX;y=height/2-centerY} } -- cgit v0.12 From 62b51f36c41fdef46b785d8f3a9443c016a9263a Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 14:27:13 +1000 Subject: Use console.log, not print --- examples/declarative/behaviours/test.qml | 2 +- examples/declarative/extending/binding/example.qml | 2 +- examples/declarative/extending/signal/example.qml | 2 +- .../declarative/extending/valuesource/example.qml | 2 +- examples/declarative/focusscope/test.qml | 10 ++++----- examples/declarative/focusscope/test3.qml | 4 ++-- examples/declarative/focusscope/test4.qml | 10 ++++----- examples/declarative/mouseregion/mouse.qml | 24 +++++++++++----------- .../tutorials/samegame/samegame1/samegame.qml | 2 +- examples/declarative/xmldata/daringfireball.qml | 2 +- examples/declarative/xmldata/yahoonews.qml | 2 +- examples/declarative/xmlhttprequest/test.qml | 18 ++++++++-------- 12 files changed, 40 insertions(+), 40 deletions(-) diff --git a/examples/declarative/behaviours/test.qml b/examples/declarative/behaviours/test.qml index 4a44fd7..1869c45 100644 --- a/examples/declarative/behaviours/test.qml +++ b/examples/declarative/behaviours/test.qml @@ -7,7 +7,7 @@ Rectangle { id: page MouseRegion { anchors.fill: parent - onClicked: { bluerect.parent = page; print(mouseX); bluerect.x = mouseX; } + onClicked: { bluerect.parent = page; console.log(mouseX); bluerect.x = mouseX; } } MyRect { color: "green" diff --git a/examples/declarative/extending/binding/example.qml b/examples/declarative/extending/binding/example.qml index 352bb70..b66bc86 100644 --- a/examples/declarative/extending/binding/example.qml +++ b/examples/declarative/extending/binding/example.qml @@ -11,7 +11,7 @@ BirthdayParty { shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } } // ![0] - onPartyStarted: print("This party started rockin' at " + time); + onPartyStarted: console.log("This party started rockin' at " + time); Boy { diff --git a/examples/declarative/extending/signal/example.qml b/examples/declarative/extending/signal/example.qml index e46bf32..c7d4792 100644 --- a/examples/declarative/extending/signal/example.qml +++ b/examples/declarative/extending/signal/example.qml @@ -2,7 +2,7 @@ import People 1.0 // ![0] BirthdayParty { - onPartyStarted: print("This party started rockin' at " + time); + onPartyStarted: console.log("This party started rockin' at " + time); // ![0] celebrant: Boy { diff --git a/examples/declarative/extending/valuesource/example.qml b/examples/declarative/extending/valuesource/example.qml index 6d47350..7cdf8c0 100644 --- a/examples/declarative/extending/valuesource/example.qml +++ b/examples/declarative/extending/valuesource/example.qml @@ -5,7 +5,7 @@ BirthdayParty { speaker: HappyBirthday { name: "Bob Jones" } // ![0] - onPartyStarted: print("This party started rockin' at " + time); + onPartyStarted: console.log("This party started rockin' at " + time); celebrant: Boy { diff --git a/examples/declarative/focusscope/test.qml b/examples/declarative/focusscope/test.qml index ab5a143..e4332e7 100644 --- a/examples/declarative/focusscope/test.qml +++ b/examples/declarative/focusscope/test.qml @@ -5,13 +5,13 @@ Rectangle { width: 800 height: 600 - Keys.onDigit9Pressed: print("Error - Root") + Keys.onDigit9Pressed: console.log("Error - Root") FocusScope { id: myScope focus: true - Keys.onDigit9Pressed: print("Error - FocusScope") + Keys.onDigit9Pressed: console.log("Error - FocusScope") Rectangle { height: 120 @@ -27,7 +27,7 @@ Rectangle { width: 100; height: 100; color: "green" border.width: 5 border.color: wantsFocus?"blue":"black" - Keys.onDigit9Pressed: print("Top Left"); + Keys.onDigit9Pressed: console.log("Top Left"); KeyNavigation.right: item2 focus: true @@ -44,7 +44,7 @@ Rectangle { border.width: 5 border.color: wantsFocus?"blue":"black" KeyNavigation.left: item1 - Keys.onDigit9Pressed: print("Top Right"); + Keys.onDigit9Pressed: console.log("Top Right"); Rectangle { width: 50; height: 50; anchors.centerIn: parent @@ -64,7 +64,7 @@ Rectangle { border.width: 5 border.color: wantsFocus?"blue":"black" - Keys.onDigit9Pressed: print("Bottom Left"); + Keys.onDigit9Pressed: console.log("Bottom Left"); KeyNavigation.up: myScope Rectangle { diff --git a/examples/declarative/focusscope/test3.qml b/examples/declarative/focusscope/test3.qml index 1b3181b..9344d07 100644 --- a/examples/declarative/focusscope/test3.qml +++ b/examples/declarative/focusscope/test3.qml @@ -23,10 +23,10 @@ Rectangle { FocusScope { id: root width: 50; height: 50; - Keys.onDigit9Pressed: print("Error - " + name) + Keys.onDigit9Pressed: console.log("Error - " + name) Rectangle { focus: true - Keys.onDigit9Pressed: print(name) + Keys.onDigit9Pressed: console.log(name) width: 50; height: 50; color: root.ListView.isCurrentItem?"red":"green" Text { text: name; anchors.centerIn: parent } diff --git a/examples/declarative/focusscope/test4.qml b/examples/declarative/focusscope/test4.qml index 5d4fe35..cc96df9 100644 --- a/examples/declarative/focusscope/test4.qml +++ b/examples/declarative/focusscope/test4.qml @@ -5,12 +5,12 @@ Rectangle { width: 800 height: 600 - Keys.onDigit9Pressed: print("Error - Root") + Keys.onDigit9Pressed: console.log("Error - Root") FocusScope { id: myScope - Keys.onDigit9Pressed: print("Error - FocusScope") + Keys.onDigit9Pressed: console.log("Error - FocusScope") Rectangle { height: 120 @@ -26,7 +26,7 @@ Rectangle { width: 100; height: 100; color: "green" border.width: 5 border.color: wantsFocus?"blue":"black" - Keys.onDigit9Pressed: print("Error - Top Left"); + Keys.onDigit9Pressed: console.log("Error - Top Left"); KeyNavigation.right: item2 focus: true @@ -43,7 +43,7 @@ Rectangle { border.width: 5 border.color: wantsFocus?"blue":"black" KeyNavigation.left: item1 - Keys.onDigit9Pressed: print("Error - Top Right"); + Keys.onDigit9Pressed: console.log("Error - Top Right"); Rectangle { width: 50; height: 50; anchors.centerIn: parent @@ -63,7 +63,7 @@ Rectangle { border.width: 5 border.color: wantsFocus?"blue":"black" - Keys.onDigit9Pressed: print("Error - Bottom Left"); + Keys.onDigit9Pressed: console.log("Error - Bottom Left"); KeyNavigation.up: myScope Rectangle { diff --git a/examples/declarative/mouseregion/mouse.qml b/examples/declarative/mouseregion/mouse.qml index 91f3b6e..d07d471 100644 --- a/examples/declarative/mouseregion/mouse.qml +++ b/examples/declarative/mouseregion/mouse.qml @@ -10,13 +10,13 @@ Rectangle { MouseRegion { hoverEnabled: true acceptedButtons: Qt.LeftButton | Qt.RightButton - onPressed: { print('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') } - onReleased: { print('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') } - onClicked: { print('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')') } - onDoubleClicked: { print('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')') } - onPressAndHold: { print('press and hold') } - onEntered: { print('entered ' + pressed) } - onExited: { print('exited ' + pressed) } + onPressed: { console.log('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') } + onReleased: { console.log('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') } + onClicked: { console.log('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')') } + onDoubleClicked: { console.log('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')') } + onPressAndHold: { console.log('press and hold') } + onEntered: { console.log('entered ' + pressed) } + onExited: { console.log('exited ' + pressed) } anchors.fill: parent } } @@ -29,11 +29,11 @@ Rectangle { drag.axis: "XAxis" drag.minimumX: 0 drag.maximumX: 150 - onPressed: { print('press') } - onReleased: { print('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')') } - onClicked: { print('click' + '(wasHeld: ' + mouse.wasHeld + ')') } - onDoubleClicked: { print('double click') } - onPressAndHold: { print('press and hold') } + onPressed: { console.log('press') } + onReleased: { console.log('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')') } + onClicked: { console.log('click' + '(wasHeld: ' + mouse.wasHeld + ')') } + onDoubleClicked: { console.log('double click') } + onPressAndHold: { console.log('press and hold') } anchors.fill: parent } } diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml index 289579a..fad2175 100644 --- a/examples/declarative/tutorials/samegame/samegame1/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame1/samegame.qml @@ -24,7 +24,7 @@ Rectangle { anchors.bottom: Screen.bottom Button { - id: btnA; text: "New Game"; onClicked: print("Implement me!"); + id: btnA; text: "New Game"; onClicked: console.log("Implement me!"); anchors.left: parent.left; anchors.leftMargin: 3 anchors.verticalCenter: parent.verticalCenter } diff --git a/examples/declarative/xmldata/daringfireball.qml b/examples/declarative/xmldata/daringfireball.qml index 938bdd5..456f309 100644 --- a/examples/declarative/xmldata/daringfireball.qml +++ b/examples/declarative/xmldata/daringfireball.qml @@ -33,7 +33,7 @@ Rectangle { text: content anchors.top: titleText.bottom width: 580; wrap: true - onLinkActivated: { print('link clicked: ' + link) } + onLinkActivated: { console.log('link clicked: ' + link) } } } } diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml index 4add361..bd14516 100644 --- a/examples/declarative/xmldata/yahoonews.qml +++ b/examples/declarative/xmldata/yahoonews.qml @@ -37,7 +37,7 @@ Rectangle { x: 10; y: 5 text: '' + title + '' font.bold: true; font.family: "Helvetica"; font.pointSize: 14 - onLinkActivated: { print('link clicked: ' + link) } + onLinkActivated: { console.log('link clicked: ' + link) } } Text { diff --git a/examples/declarative/xmlhttprequest/test.qml b/examples/declarative/xmlhttprequest/test.qml index 18447e5..18e328b 100644 --- a/examples/declarative/xmlhttprequest/test.qml +++ b/examples/declarative/xmlhttprequest/test.qml @@ -10,21 +10,21 @@ Rectangle { var doc = new XMLHttpRequest(); doc.onreadystatechange = function() { if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) { - print ("Headers -->"); - print (doc.getAllResponseHeaders ()); - print ("Last modified -->"); - print (doc.getResponseHeader ("Last-Modified")); + console.log("Headers -->"); + console.log(doc.getAllResponseHeaders ()); + console.log("Last modified -->"); + console.log(doc.getResponseHeader ("Last-Modified")); } else if (doc.readyState == XMLHttpRequest.DONE) { var a = doc.responseXML.documentElement; for (var ii = 0; ii < a.childNodes.length; ++ii) { - print (a.childNodes[ii].nodeName); + console.log(a.childNodes[ii].nodeName); } - print ("Headers -->"); - print (doc.getAllResponseHeaders ()); - print ("Last modified -->"); - print (doc.getResponseHeader ("Last-Modified")); + console.log("Headers -->"); + console.log(doc.getAllResponseHeaders ()); + console.log("Last modified -->"); + console.log(doc.getResponseHeader ("Last-Modified")); } } -- cgit v0.12 From 8ac4581718767c498192cdffdfc97211d0030e7b Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 14:27:32 +1000 Subject: Use console.log, not print --- demos/declarative/twitter/content/AuthView.qml | 2 +- demos/declarative/webbrowser/webbrowser.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/declarative/twitter/content/AuthView.qml b/demos/declarative/twitter/content/AuthView.qml index c924649..8fb00f8 100644 --- a/demos/declarative/twitter/content/AuthView.qml +++ b/demos/declarative/twitter/content/AuthView.qml @@ -30,7 +30,7 @@ Item { Item { id: tabber //Note: it's not working yet - Keys.onPressed: {if(event.key == Qt.Key_Tab){print('Tab works!'); passIn.focus = true; accept(); }} + Keys.onPressed: {if(event.key == Qt.Key_Tab){console.log('Tab works!'); passIn.focus = true; accept(); }} } } } diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 345c9af..bfc0749 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -196,7 +196,7 @@ Item { fillColor: "white" focus: true - onAlert: print(message) + onAlert: console.log(message) function doZoom(zoom,centerX,centerY) { -- cgit v0.12 From ca1ed2bd2528d1474c870d1b508c65b1bf9442da Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 23 Nov 2009 15:40:24 +1000 Subject: Fix occasionally-failing debug tests. --- tests/auto/declarative/shared/debugutil.cpp | 9 +++++---- tests/auto/declarative/shared/debugutil_p.h | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/auto/declarative/shared/debugutil.cpp b/tests/auto/declarative/shared/debugutil.cpp index 7008529..8f6fdef 100644 --- a/tests/auto/declarative/shared/debugutil.cpp +++ b/tests/auto/declarative/shared/debugutil.cpp @@ -88,8 +88,8 @@ void QmlDebugTestService::messageReceived(const QByteArray &ba) void QmlDebugTestService::enabledChanged(bool e) { - emit enabledStateChanged(); enabled = e; + emit enabledStateChanged(); } @@ -100,17 +100,18 @@ QmlDebugTestClient::QmlDebugTestClient(const QString &s, QmlDebugConnection *c) QByteArray QmlDebugTestClient::waitForResponse() { - QSignalSpy spy(this, SIGNAL(serverMessage(QByteArray))); + lastMsg.clear(); QmlDebugTest::waitForSignal(this, SIGNAL(serverMessage(QByteArray))); - if (spy.count() == 0) { + if (lastMsg.isEmpty()) { qWarning() << "tst_QmlDebugClient: no response from server!"; return QByteArray(); } - return spy.at(0).at(0).value(); + return lastMsg; } void QmlDebugTestClient::messageReceived(const QByteArray &ba) { + lastMsg = ba; emit serverMessage(ba); } diff --git a/tests/auto/declarative/shared/debugutil_p.h b/tests/auto/declarative/shared/debugutil_p.h index 665aeda..cb20f5c 100644 --- a/tests/auto/declarative/shared/debugutil_p.h +++ b/tests/auto/declarative/shared/debugutil_p.h @@ -119,6 +119,9 @@ signals: protected: virtual void messageReceived(const QByteArray &ba); + +private: + QByteArray lastMsg; }; class tst_QmlDebug_Thread : public QThread -- cgit v0.12 From 222f6954057b271745fa6158f14b331de2f032d8 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 23 Nov 2009 15:40:46 +1000 Subject: Doc. --- doc/src/declarative/globalobject.qdoc | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc index e983ad0..e3c8b9a 100644 --- a/doc/src/declarative/globalobject.qdoc +++ b/doc/src/declarative/globalobject.qdoc @@ -64,7 +64,7 @@ files. The Qt object contains all enums in the Qt namespace. For example, you can access the AlignLeft member of the Qt::AlignmentFlag enum with \c Qt.AlignLeft. -For a full list of enums, see the Qt Namespace documentation. +For a full list of enums, see the \l{Qt Namespace} documentation. \section2 Types The Qt object also contains helper functions for creating objects of specific @@ -88,20 +88,20 @@ This function returns a Color with the specified \c red, \c green, \c blue and \ This function returns a Color with the specified \c hue, \c saturation, \c lightness and \c alpha components. All components should be in the range 0-1 inclusive. \section3 Qt.rect(int x, int y, int width, int height) -This function returns a Rect with the top-left corner at \c x,\c y and the specified \c width and \c height. +This function returns a Rect with the top-left corner at \c x, \c y and the specified \c width and \c height. \section3 Qt.point(int x, int y) This function returns a Point with the specified \c x and \c y coordinates. \section3 Qt.size(int width, int height) -This function returns as Size with the specified width and height. +This function returns as Size with the specified \c width and \c height. \section3 Qt.vector3d(real x, real y, real z) -This function returns a Vector3D with the specified x, y and z. +This function returns a Vector3D with the specified \c x, \c y and \c z. \section2 Functions The Qt object also contains the following miscellaneous functions which expose Qt functionality for use in QML. \section3 Qt.lighter(color baseColor) This function returns a color 50% lighter than \c baseColor. See QColor::lighter() for further details. \section3 Qt.darker(color baseColor) -This function returns a color 50% darker than \c baseColor. See QColor::lighter() for further details. +This function returns a color 50% darker than \c baseColor. See QColor::darker() for further details. \section3 Qt.tint(color baseColor, color tintColor) This function allows tinting one color with another. @@ -117,6 +117,16 @@ This function returns a color 50% darker than \c baseColor. See QColor::lighter( \section3 Qt.closestAngle(number fromAngle, number toAngle) This function returns an equivalent angle to toAngle, such that the difference between fromAngle and toAngle is never more than 180 degrees. This is useful when animating angles using a NumberAnimation, which does not know about equivalent angles, when you always want to take the shortest path. +For example, the following would rotate myItem counterclockwise from 350 degrees to 10 degrees, for a total of 340 degrees of rotation. +\qml +NumberAnimation { target: myItem; property: "rotation"; from: 350; to: 10 } +\endqml + +while the following would rotate myItem clockwise from 350 degrees to 370 degrees (which is visually equivilant to 10 degrees), for a total of 20 degrees of rotation. +\qml +NumberAnimation { target: myItem; property: "rotation"; from: 350; to: Qt.closetAngle(350, 10) } +\endqml + \section3 Qt.playSound(url soundLocation) This function plays the audio file located at \c soundLocation. Only .wav files are supported. -- cgit v0.12 From b204fd2bc702e0ff3823b2b74de338c5be4ac0b3 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 15:45:39 +1000 Subject: Check error messages returned. --- .../qmlgraphicsimage/tst_qmlgraphicsimage.cpp | 34 +++++++++++++--------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp b/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp index 5ce5faf..784ad42 100644 --- a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp +++ b/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp @@ -106,11 +106,26 @@ void tst_qmlgraphicsimage::noSource() delete obj; } +void tst_qmlgraphicsimage::imageSource_data() +{ + QTest::addColumn("source"); + QTest::addColumn("remote"); + QTest::addColumn("error"); + + QTest::newRow("local") << SRCDIR "/data/colors.png" << false << ""; + QTest::newRow("local not found") << SRCDIR "/data/no-such-file.png" << false + << "Cannot open QUrl( \"file://" SRCDIR "/data/no-such-file.png\" ) "; + QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << ""; + QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true + << "Network error loading QUrl( \"" SERVER_ADDR "/no-such-file.png\" ) " + "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" "; +} + void tst_qmlgraphicsimage::imageSource() { QFETCH(QString, source); QFETCH(bool, remote); - QFETCH(bool, valid); + QFETCH(QString, error); TestHTTPServer server(SERVER_PORT); if (remote) { @@ -118,6 +133,9 @@ void tst_qmlgraphicsimage::imageSource() server.serveDirectory(SRCDIR "/data"); } + if (!error.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); + QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\" }"; QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); QmlGraphicsImage *obj = qobject_cast(component.create()); @@ -128,7 +146,7 @@ void tst_qmlgraphicsimage::imageSource() QCOMPARE(obj->source(), remote ? source : QUrl::fromLocalFile(source)); - if (valid) { + if (error.isEmpty()) { TRY_WAIT(obj->status() == QmlGraphicsImage::Ready); QCOMPARE(obj->width(), 120.); QCOMPARE(obj->height(), 120.); @@ -162,18 +180,6 @@ void tst_qmlgraphicsimage::clearSource() QCOMPARE(obj->progress(), 0.0); } -void tst_qmlgraphicsimage::imageSource_data() -{ - QTest::addColumn("source"); - QTest::addColumn("remote"); - QTest::addColumn("valid"); - - QTest::newRow("local") << SRCDIR "/data/colors.png" << false << true; - QTest::newRow("local not found") << SRCDIR "/data/no-such-file.png" << false << false; - QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << true; - QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true << false; -} - void tst_qmlgraphicsimage::resized() { QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }"; -- cgit v0.12 From da3a7ff361104e57b032b56c49e5cc231304a086 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 15:48:44 +1000 Subject: Fix warning --- tests/auto/declarative/qmlgraphicsflickable/data/flickable02.qml | 2 +- tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml | 2 +- tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/declarative/qmlgraphicsflickable/data/flickable02.qml b/tests/auto/declarative/qmlgraphicsflickable/data/flickable02.qml index cf98dd9..3e08359 100644 --- a/tests/auto/declarative/qmlgraphicsflickable/data/flickable02.qml +++ b/tests/auto/declarative/qmlgraphicsflickable/data/flickable02.qml @@ -8,7 +8,7 @@ Flickable { id: row Repeater { model: 4 - Rectangle { width: 200; height: 300; color: dayColor } + Rectangle { width: 200; height: 300; color: "blue" } } } } diff --git a/tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml b/tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml index 001bf2f..3ed173d 100644 --- a/tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml +++ b/tests/auto/declarative/qmlgraphicsflickable/data/flickable03.qml @@ -8,7 +8,7 @@ Flickable { id: column Repeater { model: 4 - Rectangle { width: 200; height: 300; color: dayColor } + Rectangle { width: 200; height: 300; color: "blue" } } } } diff --git a/tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml b/tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml index 5a27869..1425d85 100644 --- a/tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml +++ b/tests/auto/declarative/qmlgraphicsflickable/data/flickable04.qml @@ -10,7 +10,7 @@ Flickable { id: column Repeater { model: 4 - Rectangle { width: 200; height: 300; color: dayColor } + Rectangle { width: 200; height: 300; color: "blue" } } } } -- cgit v0.12 From effd2866ae343b858c69a66b61ececcd455d59d2 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 23 Nov 2009 16:05:08 +1000 Subject: QmlView doc. --- src/declarative/util/qmlview.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qmlview.cpp index 63115bb..c981cde 100644 --- a/src/declarative/util/qmlview.cpp +++ b/src/declarative/util/qmlview.cpp @@ -168,6 +168,9 @@ public: view->execute(); ... \endcode + + To receive errors related to loading and executing QML with QmlView, + you can connect to the errors() signal. */ /*! -- cgit v0.12 From 5e2ecb4bb92daef8eb37622484a9fdf603f8536d Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 16:16:17 +1000 Subject: check warnings --- .../tst_qmlgraphicsborderimage.cpp | 38 ++++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp index f23c7d7..bcdfa2e 100644 --- a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp +++ b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp @@ -112,12 +112,27 @@ void tst_qmlgraphicsborderimage::noSource() delete obj; } +void tst_qmlgraphicsborderimage::imageSource_data() +{ + QTest::addColumn("source"); + QTest::addColumn("remote"); + QTest::addColumn("error"); + + QTest::newRow("local") << SRCDIR "/data/colors.png" << false << ""; + QTest::newRow("local not found") << SRCDIR "/data/no-such-file.png" << false + << "Cannot open QUrl( \"file://" SRCDIR "/data/no-such-file.png\" ) "; + QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << ""; + QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true + << "Network error loading QUrl( \"" SERVER_ADDR "/no-such-file.png\" ) " + "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" "; +} + void tst_qmlgraphicsborderimage::imageSource() { QFETCH(QString, source); - QFETCH(bool, valid); + QFETCH(bool, remote); + QFETCH(QString, error); - bool remote = source.startsWith("http"); TestHTTPServer *server = 0; if (remote) { server = new TestHTTPServer(SERVER_PORT); @@ -125,6 +140,9 @@ void tst_qmlgraphicsborderimage::imageSource() server->serveDirectory(SRCDIR "/data"); } + if (!error.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); + QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }"; QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); QmlGraphicsBorderImage *obj = qobject_cast(component.create()); @@ -135,7 +153,7 @@ void tst_qmlgraphicsborderimage::imageSource() QCOMPARE(obj->source(), remote ? source : QUrl::fromLocalFile(source)); - if (valid) { + if (error.isEmpty()) { TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Ready); QCOMPARE(obj->width(), 120.); QCOMPARE(obj->height(), 120.); @@ -168,17 +186,6 @@ void tst_qmlgraphicsborderimage::clearSource() QCOMPARE(obj->height(), 0.); } -void tst_qmlgraphicsborderimage::imageSource_data() -{ - QTest::addColumn("source"); - QTest::addColumn("valid"); - - QTest::newRow("local") << SRCDIR "/data/colors.png" << true; - QTest::newRow("local not found") << SRCDIR "/data/no-such-file.png" << false; - QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true; - QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << false; -} - void tst_qmlgraphicsborderimage::resized() { QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }"; @@ -290,6 +297,9 @@ void tst_qmlgraphicsborderimage::sciSource_data() void tst_qmlgraphicsborderimage::invalidSciFile() { + QTest::ignoreMessage(QtWarningMsg, "Unknown tile rule specified. Using Stretch "); // for "Roun" + QTest::ignoreMessage(QtWarningMsg, "Unknown tile rule specified. Using Stretch "); // for "Repea" + QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/invalid.sci\"; width: 300; height: 300 }"; QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); QmlGraphicsBorderImage *obj = qobject_cast(component.create()); -- cgit v0.12 From 4c72b0441380fd43b8ca63c9b7159adfb89c60e6 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 23 Nov 2009 16:20:57 +1000 Subject: QmlView doc. --- src/declarative/util/qmlview.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qmlview.cpp index c981cde..62bcc07 100644 --- a/src/declarative/util/qmlview.cpp +++ b/src/declarative/util/qmlview.cpp @@ -167,6 +167,7 @@ public: ... view->execute(); ... + view->show(); \endcode To receive errors related to loading and executing QML with QmlView, -- cgit v0.12 From 8bbbb67aa06077678a0bd865783efc1212a918c3 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 23 Nov 2009 17:01:36 +1000 Subject: Avoid warnings --- tests/auto/declarative/anchors/data/anchors.qml | 13 +------------ tests/auto/declarative/anchors/tst_anchors.cpp | 13 +++++-------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/tests/auto/declarative/anchors/data/anchors.qml b/tests/auto/declarative/anchors/data/anchors.qml index e6bed48..b64d0b0 100644 --- a/tests/auto/declarative/anchors/data/anchors.qml +++ b/tests/auto/declarative/anchors/data/anchors.qml @@ -120,7 +120,7 @@ Rectangle { anchors.centerIn: masterRect } Rectangle { - id: rect23a; objectName: "rect23a" + id: rect23; objectName: "rect23" anchors.left: masterRect.left anchors.leftMargin: 5 anchors.right: masterRect.right @@ -131,17 +131,6 @@ Rectangle { anchors.bottomMargin: 5 } Rectangle { - id: rect23b; objectName: "rect23b" - anchors.left: rect23a.anchors.left - anchors.leftMargin: rect23a.anchors.leftMargin - anchors.right: rect23a.anchors.right - anchors.rightMargin: rect23a.anchors.rightMargin - anchors.top: rect23a.anchors.top - anchors.topMargin: rect23a.anchors.topMargin - anchors.bottom: rect23a.anchors.bottom - anchors.bottomMargin: rect23a.anchors.bottomMargin - } - Rectangle { id: rect24; objectName: "rect24" width: 10; height: 10 anchors.horizontalCenter: masterRect.left diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp index d65d289..3011fdc 100644 --- a/tests/auto/declarative/anchors/tst_anchors.cpp +++ b/tests/auto/declarative/anchors/tst_anchors.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include +#include #include #include #include @@ -144,14 +145,10 @@ void tst_anchors::basicAnchors() QCOMPARE(findItem(view->root(), QLatin1String("rect22"))->y(), 5.0); //margins - QCOMPARE(findItem(view->root(), QLatin1String("rect23a"))->x(), 31.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect23a"))->y(), 5.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect23a"))->width(), 86.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect23a"))->height(), 10.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect23b"))->x(), 31.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect23b"))->y(), 5.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect23b"))->width(), 86.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect23b"))->height(), 10.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect23"))->x(), 31.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect23"))->y(), 5.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect23"))->width(), 86.0); + QCOMPARE(findItem(view->root(), QLatin1String("rect23"))->height(), 10.0); // offsets QCOMPARE(findItem(view->root(), QLatin1String("rect24"))->x(), 26.0); -- cgit v0.12 From 65a507009c543ddf3272f5a52013f33c7d5965bc Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 23 Nov 2009 17:10:24 +1000 Subject: Parameter order was wrong. (broke eg. webbrowser side shadows) --- src/declarative/graphicsitems/qmlgraphicsborderimage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp index 6f953bc..d7d725b 100644 --- a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp @@ -394,7 +394,7 @@ void QmlGraphicsBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem * p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth); const QmlGraphicsScaleGrid *border = d->getScaleGrid(); - QMargins margins(border->top(), border->left(), border->bottom(), border->right()); + QMargins margins(border->left(), border->top(), border->right(), border->bottom()); QTileRules rules((Qt::TileRule)d->horizontalTileMode, (Qt::TileRule)d->verticalTileMode); qDrawBorderPixmap(p, QRect(0, 0, (int)d->width, (int)d->height), margins, d->pix, d->pix.rect(), margins, rules); if (d->smooth) { -- cgit v0.12