summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-11-11 02:30:25 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-11-11 02:30:25 (GMT)
commitd81b40f2ae2e0519aabc69fc177bbc82a74c87b3 (patch)
tree7cbafe0e8c22c3351def3f68c5ee87ff740b0fdd /tests/auto
parentb6b0b5d7f211e10beb76711fcecdf068af34fdfd (diff)
downloadQt-d81b40f2ae2e0519aabc69fc177bbc82a74c87b3.zip
Qt-d81b40f2ae2e0519aabc69fc177bbc82a74c87b3.tar.gz
Qt-d81b40f2ae2e0519aabc69fc177bbc82a74c87b3.tar.bz2
test multiple-windows
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/data/newwindows.html16
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml32
-rw-r--r--tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp12
3 files changed, 60 insertions, 0 deletions
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 @@
+<html>
+<head>
+<script type="text/javascript">
+<!--
+function clickTheLink()
+{
+ var ev = document.createEvent('MouseEvents');
+ ev.initEvent( "click", true, false );
+ document.getElementById('thelink').dispatchEvent(ev);
+}
+// -->
+</script>
+</head>
+<h1>Multiple windows...</h1>
+
+<a id=thelink target="_blank" href="newwindows.html">Popup!</a>
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 <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
#include <private/qmlgraphicswebview_p.h>
+#include <private/qmlgraphicspositioners_p.h>
#include <QtWebKit/qwebpage.h>
#include <QtWebKit/qwebframe.h>
#include <QtCore/qdir.h>
@@ -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<QmlGraphicsGrid*>(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"));