Title: [87796] trunk/Source/WebKit/qt
Revision
87796
Author
[email protected]
Date
2011-06-01 05:16:09 -0700 (Wed, 01 Jun 2011)

Log Message

2011-06-01  Caio Marcelo de Oliveira Filho  <[email protected]>

        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.

Modified Paths

Diff

Modified: trunk/Source/WebKit/qt/ChangeLog (87795 => 87796)


--- trunk/Source/WebKit/qt/ChangeLog	2011-06-01 12:01:20 UTC (rev 87795)
+++ trunk/Source/WebKit/qt/ChangeLog	2011-06-01 12:16:09 UTC (rev 87796)
@@ -1,3 +1,26 @@
+2011-06-01  Caio Marcelo de Oliveira Filho  <[email protected]>
+
+        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  <[email protected]>
 
         Reviewed by Andreas Kling.

Modified: trunk/Source/WebKit/qt/tests/qdeclarativewebview/resources/newwindows.html (87795 => 87796)


--- trunk/Source/WebKit/qt/tests/qdeclarativewebview/resources/newwindows.html	2011-06-01 12:01:20 UTC (rev 87795)
+++ trunk/Source/WebKit/qt/tests/qdeclarativewebview/resources/newwindows.html	2011-06-01 12:16:09 UTC (rev 87796)
@@ -1,3 +1,4 @@
+<!DOCTYPE html>
 <html>
 <head>
 <script type="text/_javascript_">
@@ -11,6 +12,9 @@
 // -->
 </script>
 </head>
+<body>
 <h1>Multiple windows...</h1>
 
 <a id=thelink target="_blank" href=""
+</body>
+</html>

Modified: trunk/Source/WebKit/qt/tests/qdeclarativewebview/resources/newwindows.qml (87795 => 87796)


--- trunk/Source/WebKit/qt/tests/qdeclarativewebview/resources/newwindows.qml	2011-06-01 12:01:20 UTC (rev 87795)
+++ trunk/Source/WebKit/qt/tests/qdeclarativewebview/resources/newwindows.qml	2011-06-01 12:16:09 UTC (rev 87796)
@@ -7,28 +7,45 @@
     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()");
+        }
+    }
 }

Modified: trunk/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.cpp (87795 => 87796)


--- trunk/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.cpp	2011-06-01 12:01:20 UTC (rev 87795)
+++ trunk/Source/WebKit/qt/tests/qdeclarativewebview/tst_qdeclarativewebview.cpp	2011-06-01 12:16:09 UTC (rev 87796)
@@ -272,17 +272,21 @@
 
 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()
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to