diff options
Diffstat (limited to 'tests')
13 files changed, 381 insertions, 4 deletions
diff --git a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp index 9032300..308cdd6 100644 --- a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp +++ b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp @@ -59,6 +59,7 @@ private slots: void basicProperties(); void historyNav(); void multipleWindows(); + void elementAreaAt(); void loadError(); void setHtml(); void javaScript(); @@ -258,6 +259,21 @@ void tst_qmlgraphicswebview::setHtml() QCOMPARE(wv->html(),QString("<html><head></head><body><p>This is a <b>string</b> set on the WebView</p></body></html>")); } +void tst_qmlgraphicswebview::elementAreaAt() +{ + QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/elements.qml")); + checkNoErrors(component); + QmlGraphicsWebView *wv = qobject_cast<QmlGraphicsWebView*>(component.create()); + QVERIFY(wv != 0); + QTRY_COMPARE(wv->progress(), 1.0); + + QCOMPARE(wv->elementAreaAt(40,30,100,100),QRect(1,1,75,54)); // Area A in data/elements.html + QCOMPARE(wv->elementAreaAt(130,30,200,100),QRect(78,3,110,50)); // Area B + QCOMPARE(wv->elementAreaAt(40,30,400,400),QRect(0,0,310,100)); // Whole view + QCOMPARE(wv->elementAreaAt(130,30,280,280),QRect(76,1,223,54)); // Area BC + QCOMPARE(wv->elementAreaAt(130,30,400,400),QRect(0,0,310,100)); // Whole view +} + void tst_qmlgraphicswebview::javaScript() { QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/javaScript.qml")); diff --git a/tests/auto/declarative/qmllanguage/data/cppnamespace.2.qml b/tests/auto/declarative/qmllanguage/data/cppnamespace.2.qml new file mode 100644 index 0000000..e3b32ca --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/cppnamespace.2.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MySecondNamespacedType { + list: [ MyNamespacedType {} ] +} diff --git a/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp b/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp index ece6030..fe2658c 100644 --- a/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp +++ b/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp @@ -41,7 +41,7 @@ #include <qtest.h> #include <QtDeclarative/qmlengine.h> #include <QtDeclarative/qmlcontext.h> -#include <private/qmlpropertymap_p.h> +#include <QtDeclarative/qmlpropertymap.h> #include <QtDeclarative/qmlcomponent.h> #include <private/qmlgraphicstext_p.h> #include <QSignalSpy> diff --git a/tests/auto/declarative/qmlqt/data/md5.qml b/tests/auto/declarative/qmlqt/data/md5.qml new file mode 100644 index 0000000..3c96a6b --- /dev/null +++ b/tests/auto/declarative/qmlqt/data/md5.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +Object { + property string test1: Qt.md5() + property string test2: Qt.md5("Hello World") +} diff --git a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp index e9c9052..13f4904 100644 --- a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp +++ b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp @@ -46,6 +46,7 @@ #include <QmlComponent> #include <QDir> #include <QVector3D> +#include <QCryptographicHash> class tst_qmlqt : public QObject { @@ -67,6 +68,7 @@ private slots: void closestAngle(); void playSound(); void openUrlExternally(); + void md5(); private: QmlEngine engine; @@ -279,6 +281,19 @@ void tst_qmlqt::openUrlExternally() QVERIFY(false); } +void tst_qmlqt::md5() +{ + QmlComponent component(&engine, TEST_FILE("md5.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toString(), QLatin1String(QCryptographicHash::hash(QByteArray(), QCryptographicHash::Md5).toHex())); + QCOMPARE(object->property("test2").toString(), QLatin1String(QCryptographicHash::hash("Hello World", QCryptographicHash::Md5).toHex())); + + delete object; +} + + QTEST_MAIN(tst_qmlqt) #include "tst_qmlqt.moc" diff --git a/tests/auto/declarative/xmlhttprequest/data/cdata.qml b/tests/auto/declarative/xmlhttprequest/data/cdata.qml new file mode 100644 index 0000000..5faa359 --- /dev/null +++ b/tests/auto/declarative/xmlhttprequest/data/cdata.qml @@ -0,0 +1,135 @@ +import Qt 4.6 + +Object { + property bool xmlTest: false + property bool dataOK: false + + Script { + function checkCData(text, whitespacetext) + { + // This is essentially a copy of text.qml/checkText() + + if (text == null) + return; + + if (text.nodeName != "#cdata-section") + return; + + if (text.nodeValue != "Hello world!") + return; + + if (text.nodeType != 4) + return; + + if (text.parentNode.nodeName != "item") + return; + + if (text.childNodes.length != 0) + return; + + if (text.firstChild != null) + return; + + if (text.lastChild != null) + return; + + if (text.previousSibling != null) + return; + + if (text.nextSibling != null) + return; + + if (text.attributes != null) + return; + + if (text.wholeText != "Hello world!") + return; + + if (text.data != "Hello world!") + return; + + if (text.length != 12) + return; + + if (text.isElementContentWhitespace != false) + return; + + if (whitespacetext.nodeName != "#cdata-section") + return; + + if (whitespacetext.nodeValue != " ") + return; + + if (whitespacetext.nodeType != 4) + return; + + if (whitespacetext.parentNode.nodeName != "item") + return; + + if (whitespacetext.childNodes.length != 0) + return; + + if (whitespacetext.firstChild != null) + return; + + if (whitespacetext.lastChild != null) + return; + + if (whitespacetext.previousSibling != null) + return; + + if (whitespacetext.nextSibling != null) + return; + + if (whitespacetext.attributes != null) + return; + + if (whitespacetext.wholeText != " ") + return; + + if (whitespacetext.data != " ") + return; + + if (whitespacetext.length != 3) + return; + + if (whitespacetext.isElementContentWhitespace != true) + return; + + + xmlTest = true; + } + + function checkXML(document) + { + checkCData(document.documentElement.childNodes[0].childNodes[0], + document.documentElement.childNodes[1].childNodes[0]); + + } + } + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", "cdata.xml"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + + dataOK = true; + + if (x.responseXML != null) + checkXML(x.responseXML); + + } + } + + x.send() + } +} + + + + + diff --git a/tests/auto/declarative/xmlhttprequest/data/cdata.xml b/tests/auto/declarative/xmlhttprequest/data/cdata.xml new file mode 100644 index 0000000..061d37c --- /dev/null +++ b/tests/auto/declarative/xmlhttprequest/data/cdata.xml @@ -0,0 +1,2 @@ +<root><item><![CDATA[Hello world!]]></item><item><![CDATA[ ]]></item></root> + diff --git a/tests/auto/declarative/xmlhttprequest/data/document.qml b/tests/auto/declarative/xmlhttprequest/data/document.qml index fe78e31..7601a10 100644 --- a/tests/auto/declarative/xmlhttprequest/data/document.qml +++ b/tests/auto/declarative/xmlhttprequest/data/document.qml @@ -10,12 +10,18 @@ Object { if (document.xmlVersion != "1.0") return; + if (document.xmlEncoding != "UTF-8") + return; + if (document.xmlStandalone != true) return; if (document.documentElement == null) return; + if (document.nodeName != "#document") + return; + if (document.nodeValue != null) return; diff --git a/tests/auto/declarative/xmlhttprequest/data/document.xml b/tests/auto/declarative/xmlhttprequest/data/document.xml index b5fbe31..fb693ea 100644 --- a/tests/auto/declarative/xmlhttprequest/data/document.xml +++ b/tests/auto/declarative/xmlhttprequest/data/document.xml @@ -1,3 +1,3 @@ -<?xml version="1.0" standalone='yes' ?> +<?xml version="1.0" encoding="UTF-8" standalone='yes'?> <root> </root> diff --git a/tests/auto/declarative/xmlhttprequest/data/element.qml b/tests/auto/declarative/xmlhttprequest/data/element.qml index a1ae2ab..79620bf 100644 --- a/tests/auto/declarative/xmlhttprequest/data/element.qml +++ b/tests/auto/declarative/xmlhttprequest/data/element.qml @@ -5,7 +5,7 @@ Object { property bool dataOK: false Script { - function checkElement(e) + function checkElement(e, person, fruit) { if (e.tagName != "root") return; @@ -47,6 +47,9 @@ Object { if (e.attributes == null) return; + if (e.attributes.length != 2) + return; + var attr1 = e.attributes["attr"]; if (attr1.nodeValue != "value") return; @@ -67,12 +70,33 @@ Object { if (attrIdx2 != null) return; + // Check person and fruit sub elements + if (person.parentNode.nodeName != "root") + return; + + if (person.previousSibling != null) + return; + + if (person.nextSibling.nodeName != "fruit") + return; + + if (fruit.parentNode.nodeName != "root") + return; + + if (fruit.previousSibling.nodeName != "person") + return; + + if (fruit.nextSibling != null) + return; + xmlTest = true; } function checkXML(document) { - checkElement(document.documentElement); + checkElement(document.documentElement, + document.documentElement.childNodes[0], + document.documentElement.childNodes[1]); } } diff --git a/tests/auto/declarative/xmlhttprequest/data/text.qml b/tests/auto/declarative/xmlhttprequest/data/text.qml new file mode 100644 index 0000000..8c97504 --- /dev/null +++ b/tests/auto/declarative/xmlhttprequest/data/text.qml @@ -0,0 +1,131 @@ +import Qt 4.6 + +Object { + property bool xmlTest: false + property bool dataOK: false + + Script { + function checkText(text, whitespacetext) + { + if (text == null) + return; + + if (text.nodeName != "#text") + return; + + if (text.nodeValue != "Hello world!") + return; + + if (text.nodeType != 3) + return; + + if (text.parentNode.nodeName != "item") + return; + + if (text.childNodes.length != 0) + return; + + if (text.firstChild != null) + return; + + if (text.lastChild != null) + return; + + if (text.previousSibling != null) + return; + + if (text.nextSibling != null) + return; + + if (text.attributes != null) + return; + + if (text.wholeText != "Hello world!") + return; + + if (text.data != "Hello world!") + return; + + if (text.length != 12) + return; + + if (text.isElementContentWhitespace != false) + return; + + if (whitespacetext.nodeName != "#text") + return; + + if (whitespacetext.nodeValue != " ") + return; + + if (whitespacetext.nodeType != 3) + return; + + if (whitespacetext.parentNode.nodeName != "item") + return; + + if (whitespacetext.childNodes.length != 0) + return; + + if (whitespacetext.firstChild != null) + return; + + if (whitespacetext.lastChild != null) + return; + + if (whitespacetext.previousSibling != null) + return; + + if (whitespacetext.nextSibling != null) + return; + + if (whitespacetext.attributes != null) + return; + + if (whitespacetext.wholeText != " ") + return; + + if (whitespacetext.data != " ") + return; + + if (whitespacetext.length != 3) + return; + + if (whitespacetext.isElementContentWhitespace != true) + return; + + xmlTest = true; + } + + function checkXML(document) + { + checkText(document.documentElement.childNodes[0].childNodes[0], + document.documentElement.childNodes[1].childNodes[0]); + + } + } + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", "text.xml"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + + dataOK = true; + + if (x.responseXML != null) + checkXML(x.responseXML); + + } + } + + x.send() + } +} + + + + diff --git a/tests/auto/declarative/xmlhttprequest/data/text.xml b/tests/auto/declarative/xmlhttprequest/data/text.xml new file mode 100644 index 0000000..e741688 --- /dev/null +++ b/tests/auto/declarative/xmlhttprequest/data/text.xml @@ -0,0 +1 @@ +<root><item>Hello world!</item><item> </item></root> diff --git a/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp b/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp index 0af7b18..100a11b 100644 --- a/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp +++ b/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp @@ -84,10 +84,14 @@ private slots: void statusText(); void responseText(); void responseXML_invalid(); + void invalidMethodUsage(); + // Attributes void document(); void element(); void attr(); + void text(); + void cdata(); // Crashes // void outstanding_request_at_shutdown(); @@ -962,6 +966,10 @@ void tst_xmlhttprequest::responseText() } } +void tst_xmlhttprequest::invalidMethodUsage() +{ +} + void tst_xmlhttprequest::responseXML_invalid() { QmlComponent component(&engine, TEST_FILE("responseXML_invalid.qml")); @@ -1017,6 +1025,34 @@ void tst_xmlhttprequest::attr() delete object; } +// Test the Text DOM element +void tst_xmlhttprequest::text() +{ + QmlComponent component(&engine, TEST_FILE("text.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("xmlTest").toBool(), true); + + delete object; +} + +// Test the CDataSection DOM element +void tst_xmlhttprequest::cdata() +{ + QmlComponent component(&engine, TEST_FILE("cdata.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("xmlTest").toBool(), true); + + delete object; +} + QTEST_MAIN(tst_xmlhttprequest) #include "tst_xmlhttprequest.moc" |