2011-06-01 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
authorcaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jun 2011 12:16:09 +0000 (12:16 +0000)
committercaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Jun 2011 12:16:09 +0000 (12:16 +0000)
        Reviewed by Tor Arne Vestbø.

        [Qt] Rewrite tst_QDeclarativeWebView::multipleWindows() to not depend on Grid internals
        https://bugs.webkit.org/show_bug.cgi?id=61739

        The skipped test was imported from Qt source repository, and used private headers
        to peek in the QML Grid element. This patch changes the QML used to expose the
        information we want to test: number of pages opened and the first page opened.

        * tests/qdeclarativewebview/resources/newwindows.html:
        Added <body> tags. We have no reason to not use them in the test.

        * tests/qdeclarativewebview/resources/newwindows.qml:
        Moved the timer out of the page component, used anchors for setting webview size,
        changed the way we count pages opened. Also changed coding style a bit.

        * tests/qdeclarativewebview/tst_qdeclarativewebview.cpp:
        (tst_QDeclarativeWebView::multipleWindows):
        We now look for properties with the information we want in the rootItem: pagesOpened and
        firstPageOpened.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@87796 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/qt/ChangeLog
Source/WebKit/qt/tests/qdeclarativewebview/resources/newwindows.html
Source/WebKit/qt/tests/qdeclarativewebview/resources/newwindows.qml
Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.cpp

index 1842c32..a0aa769 100644 (file)
@@ -1,3 +1,26 @@
+2011-06-01  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
+
+        Reviewed by Tor Arne Vestbø.
+
+        [Qt] Rewrite tst_QDeclarativeWebView::multipleWindows() to not depend on Grid internals
+        https://bugs.webkit.org/show_bug.cgi?id=61739
+
+        The skipped test was imported from Qt source repository, and used private headers
+        to peek in the QML Grid element. This patch changes the QML used to expose the
+        information we want to test: number of pages opened and the first page opened.
+
+        * tests/qdeclarativewebview/resources/newwindows.html:
+        Added <body> tags. We have no reason to not use them in the test.
+
+        * tests/qdeclarativewebview/resources/newwindows.qml:
+        Moved the timer out of the page component, used anchors for setting webview size,
+        changed the way we count pages opened. Also changed coding style a bit.
+
+        * tests/qdeclarativewebview/tst_qdeclarativewebview.cpp:
+        (tst_QDeclarativeWebView::multipleWindows):
+        We now look for properties with the information we want in the rootItem: pagesOpened and
+        firstPageOpened.
+
 2011-05-31  Rafael Brandao  <rafael.lobo@openbossa.org>
 
         Reviewed by Andreas Kling.
index dd541f9..4252d9a 100644 (file)
@@ -1,3 +1,4 @@
+<!DOCTYPE html>
 <html>
 <head>
 <script type="text/javascript">
@@ -11,6 +12,9 @@ function clickTheLink()
 // -->
 </script>
 </head>
+<body>
 <h1>Multiple windows...</h1>
 
 <a id=thelink target="_blank" href="newwindows.html">Popup!</a>
+</body>
+</html>
index e66631d..166722d 100644 (file)
@@ -7,28 +7,45 @@ Grid {
     columns: 3
     id: pages
     height: 300; width: 600
-    property int total: 0
+    property int pagesOpened: 0
+    property Item firstPageOpened: null
 
     Component {
         id: webViewPage
         Rectangle {
-            width: webView.width
-            height: webView.height
-            border.color: "gray"
+            id: thisPage
+            width: 150
+            height: 150
+            property WebView webView: wv
 
             WebView {
-                id: webView
-                width: 150 // force predictable for test
+                id: wv
+                anchors.fill: parent
                 newWindowComponent: webViewPage
                 newWindowParent: pages
                 url: "newwindows.html"
-                Timer {
-                    interval: 10; running: total<4; repeat: false;
-                    onTriggered: { if (webView.status==WebView.Ready) { total++; webView.evaluateJavaScript("clickTheLink()") } }
+                Component.onCompleted: {
+                    if (pagesOpened == 1) {
+                        pages.firstPageOpened = thisPage;
+                    }
                 }
             }
         }
     }
 
-    Loader { sourceComponent: webViewPage }
+    Loader {
+        id: originalPage
+        sourceComponent: webViewPage
+        property bool ready: status == Loader.Ready && item.webView.status == WebView.Ready
+    }
+
+    Timer {
+        interval: 10
+        running: originalPage.ready && pagesOpened < 4
+        repeat: true
+        onTriggered: {
+            pagesOpened++;
+            originalPage.item.webView.evaluateJavaScript("clickTheLink()");
+        }
+    }
 }
index da3b72f..5ce1eb1 100644 (file)
@@ -272,17 +272,21 @@ void tst_QDeclarativeWebView::loadError()
 
 void tst_QDeclarativeWebView::multipleWindows()
 {
-    QSKIP("Rework this test to not depend on QDeclarativeGrid", SkipAll);
     QDeclarativeEngine engine;
     QDeclarativeComponent component(&engine, QUrl("qrc:///resources/newwindows.qml"));
     checkNoErrors(component);
 
-//    QDeclarativeGrid *grid = qobject_cast<QDeclarativeGrid*>(component.create());
-//    QVERIFY(grid != 0);
-//    QTRY_COMPARE(grid->children().count(), 2+4); // Component, Loader (with 1 WebView), 4 new-window WebViews
-//    QDeclarativeItem* popup = qobject_cast<QDeclarativeItem*>(grid->children().at(2)); // first popup after Component and Loader.
-//    QVERIFY(popup != 0);
-//    QTRY_COMPARE(popup->x(), 150.0);
+    QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(component.create());
+    QVERIFY(rootItem);
+
+    QTRY_COMPARE(rootItem->property("pagesOpened").toInt(), 4);
+
+    QDeclarativeProperty prop(rootItem, "firstPageOpened");
+    QObject* firstPageOpened = qvariant_cast<QObject*>(prop.read());
+    QVERIFY(firstPageOpened);
+
+    QDeclarativeProperty xProp(firstPageOpened, "x");
+    QTRY_COMPARE(xProp.read().toReal(), qreal(150.0));
 }
 
 void tst_QDeclarativeWebView::newWindowComponent()