summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-05-17 19:55:05 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2011-05-18 14:29:29 -0300
commiteb133c76b8fc51399f2ca93c33346fa3bb64850e (patch)
treef4c0637e1dbcd13437e4fd7fc8fda29bf869ac15
parenta859097f565a5b973954eac86f2455ec31801a94 (diff)
downloadpyside-eb133c76b8fc51399f2ca93c33346fa3bb64850e.tar.gz
pyside-eb133c76b8fc51399f2ca93c33346fa3bb64850e.tar.xz
pyside-eb133c76b8fc51399f2ca93c33346fa3bb64850e.zip
Fix bug 803 - "QWebElementCollection.operator[] is not implemented"
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r--PySide/QtWebKit/typesystem_webkit.xml17
-rw-r--r--tests/QtWebKit/CMakeLists.txt1
-rw-r--r--tests/QtWebKit/bug_803.py18
3 files changed, 35 insertions, 1 deletions
diff --git a/PySide/QtWebKit/typesystem_webkit.xml b/PySide/QtWebKit/typesystem_webkit.xml
index 45f498e..a021a04 100644
--- a/PySide/QtWebKit/typesystem_webkit.xml
+++ b/PySide/QtWebKit/typesystem_webkit.xml
@@ -175,5 +175,20 @@
<value-type name="QWebElement" since="4.6">
<enum-type name="StyleResolveStrategy"/>
</value-type>
- <value-type name="QWebElementCollection" since="4.6"/>
+ <value-type name="QWebElementCollection" since="4.6">
+ <add-function signature="__len__">
+ <inject-code>
+ return %CPPSELF.count();
+ </inject-code>
+ </add-function>
+ <add-function signature="__getitem__">
+ <inject-code>
+ if (_i &lt; 0 || _i >= %CPPSELF.count()) {
+ PyErr_SetString(PyExc_IndexError, "index out of bounds");
+ return 0;
+ }
+ return %CONVERTTOPYTHON[QWebElement](%CPPSELF.at(_i));
+ </inject-code>
+ </add-function>
+ </value-type>
</typesystem>
diff --git a/tests/QtWebKit/CMakeLists.txt b/tests/QtWebKit/CMakeLists.txt
index 6834141..bfe5c0e 100644
--- a/tests/QtWebKit/CMakeLists.txt
+++ b/tests/QtWebKit/CMakeLists.txt
@@ -1,5 +1,6 @@
PYSIDE_TEST(bug_448.py)
PYSIDE_TEST(bug_694.py)
+PYSIDE_TEST(bug_803.py)
PYSIDE_TEST(webpage_test.py)
PYSIDE_TEST(webview_test.py)
PYSIDE_TEST(webframe_test.py)
diff --git a/tests/QtWebKit/bug_803.py b/tests/QtWebKit/bug_803.py
new file mode 100644
index 0000000..95fd546
--- /dev/null
+++ b/tests/QtWebKit/bug_803.py
@@ -0,0 +1,18 @@
+import unittest
+from PySide.QtGui import *
+from PySide.QtWebKit import *
+
+class TestBug803 (unittest.TestCase):
+
+ def testIt(self):
+ app = QApplication([])
+ page = QWebPage()
+ frame = page.mainFrame()
+ frame.setHtml("<html><head></head><body><p>1</p><p>2</p></body></html>")
+ elems = frame.findAllElements("p")
+ self.assertEqual(len(elems), 2)
+ self.assertEqual(elems[0].toPlainText(), "1")
+ self.assertEqual(elems[1].toPlainText(), "2")
+
+if __name__ == "__main__":
+ unittest.main()