From d81b40f2ae2e0519aabc69fc177bbc82a74c87b3 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 11 Nov 2009 12:30:25 +1000 Subject: test multiple-windows --- .../qmlgraphicswebview/data/newwindows.html | 16 +++++++++++ .../qmlgraphicswebview/data/newwindows.qml | 32 ++++++++++++++++++++++ .../qmlgraphicswebview/tst_qmlgraphicswebview.cpp | 12 ++++++++ 3 files changed, 60 insertions(+) create mode 100644 tests/auto/declarative/qmlgraphicswebview/data/newwindows.html create mode 100644 tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml diff --git a/tests/auto/declarative/qmlgraphicswebview/data/newwindows.html b/tests/auto/declarative/qmlgraphicswebview/data/newwindows.html new file mode 100644 index 0000000..dd541f9 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicswebview/data/newwindows.html @@ -0,0 +1,16 @@ + + + + +

Multiple windows...

+ +Popup! diff --git a/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml b/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml new file mode 100644 index 0000000..9d13715 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml @@ -0,0 +1,32 @@ +// Demonstrates opening new WebViews from HTML + +import Qt 4.6 + +Grid { + columns: 3 + id: pages + height: 300; width: 600 + property int total: 0 + + Component { + id: webViewPage + Rectangle { + width: webView.width + height: webView.height + border.color: "gray" + + WebView { + id: webView + newWindowComponent: webViewPage + newWindowParent: pages + url: "newwindows.html" + Timer { + interval: 10; running: total<4; repeat: false; + onTriggered: {total++; webView.evaluateJavaScript("clickTheLink()")} + } + } + } + } + + Loader { sourceComponent: webViewPage } +} diff --git a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp index 44319c1..9032300 100644 --- a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp +++ b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -57,6 +58,7 @@ public: private slots: void basicProperties(); void historyNav(); + void multipleWindows(); void loadError(); void setHtml(); void javaScript(); @@ -218,6 +220,16 @@ void tst_qmlgraphicswebview::historyNav() QVERIFY(!wv->stopAction()->isEnabled()); } +void tst_qmlgraphicswebview::multipleWindows() +{ + QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/newwindows.qml")); + checkNoErrors(component); + + QmlGraphicsGrid *grid = qobject_cast(component.create()); + QVERIFY(grid != 0); + QTRY_COMPARE(grid->children().count(), 2+5); // Component, Loader, 5 WebViews +} + void tst_qmlgraphicswebview::loadError() { QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/loadError.qml")); -- cgit v0.12