From 65ebb736e7d1f134b6d3dc5c620de43b9880d544 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 9 Nov 2009 13:08:26 +1000 Subject: webview JS test --- .../declarative/qmlgraphicswebview/data/javaScript.qml | 6 ++++++ .../qmlgraphicswebview/tst_qmlgraphicswebview.cpp | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/auto/declarative/qmlgraphicswebview/data/javaScript.qml b/tests/auto/declarative/qmlgraphicswebview/data/javaScript.qml index 75d0cea..28742f3 100644 --- a/tests/auto/declarative/qmlgraphicswebview/data/javaScript.qml +++ b/tests/auto/declarative/qmlgraphicswebview/data/javaScript.qml @@ -2,4 +2,10 @@ import Qt 4.6 WebView { url: "javaScript.html" + javaScriptWindowObjects: [ + Object { + property string qmlprop: "qmlvalue" + WebView.windowObjectName: "myjsname" + } + ] } diff --git a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp index 6cf6741..c05f8a6 100644 --- a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp +++ b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp @@ -59,9 +59,9 @@ private slots: void historyNav(); void loadError(); void setHtml(); + void javaScript(); void cleanupTestCase(); - private: void checkNoErrors(const QmlComponent& component); QmlEngine engine; @@ -248,6 +248,18 @@ void tst_qmlgraphicswebview::setHtml() QCOMPARE(wv->html(),QString("

This is a string set on the WebView

")); } +void tst_qmlgraphicswebview::javaScript() +{ + QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/javaScript.qml")); + checkNoErrors(component); + QmlGraphicsWebView *wv = qobject_cast(component.create()); + QVERIFY(wv != 0); + QTRY_COMPARE(wv->progress(), 1.0); + QCOMPARE(wv->evaluateJavaScript("123").toInt(), 123); + QCOMPARE(wv->evaluateJavaScript("window.status").toString(), QString("status here")); + QCOMPARE(wv->evaluateJavaScript("window.myjsname.qmlprop").toString(), QString("qmlvalue")); +} + QTEST_MAIN(tst_qmlgraphicswebview) #include "tst_qmlgraphicswebview.moc" -- cgit v0.12