aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-09-10 19:33:49 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2010-09-10 19:41:25 -0300
commitcbf12bc3a010508081d59bdac832d3e2bb9e0c2a (patch)
tree5b65bf20c22af25a8a25f1ec01cbb7faaa532bfa
parent067b49c738bc147d6a706b6f5ac6336913cb14d5 (diff)
Fix bug#254 - "QWebView.setPage() does not seem to work"
Reviewer: Lauro Moura <lauro.neto@openbossa.org> Renato Araújo <renato.filho@openbossa.org>
-rw-r--r--PySide/QtWebKit/typesystem_webkit.xml7
-rw-r--r--tests/QtWebKit/webview_test.py24
2 files changed, 29 insertions, 2 deletions
diff --git a/PySide/QtWebKit/typesystem_webkit.xml b/PySide/QtWebKit/typesystem_webkit.xml
index a3033883b..2ba3d8cd2 100644
--- a/PySide/QtWebKit/typesystem_webkit.xml
+++ b/PySide/QtWebKit/typesystem_webkit.xml
@@ -49,7 +49,12 @@
<object-type name="QWebView">
<modify-function signature="setPage(QWebPage*)">
<modify-argument index="1">
- <define-ownership class="target" owner="c++"/>
+ <reference-count action="add"/>
+ </modify-argument>
+ </modify-function>
+ <modify-function signature="page() const">
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
</modify-argument>
</modify-function>
<modify-function signature="print(QPrinter*)const" rename="print_" />
diff --git a/tests/QtWebKit/webview_test.py b/tests/QtWebKit/webview_test.py
index c06e437c3..a6a40fd5c 100644
--- a/tests/QtWebKit/webview_test.py
+++ b/tests/QtWebKit/webview_test.py
@@ -2,13 +2,18 @@
'''Test cases for QWebView'''
import unittest
+import sys
from PySide.QtCore import QObject, SIGNAL, QUrl
-from PySide.QtWebKit import QWebView
+from PySide.QtWebKit import *
from helper import adjust_filename, TimedQApplication
+class testWebPage(QWebPage):
+ def sayMyName(self):
+ return 'testWebPage'
+
class TestLoadFinished(TimedQApplication):
'''Test case for signal QWebView.loadFinished(bool)'''
@@ -33,6 +38,23 @@ class TestLoadFinished(TimedQApplication):
self.assert_(self.called)
+ def testSetPageAndGetPage(self):
+ twp = testWebPage()
+ self.view.setPage(twp)
+ del twp
+ p = self.view.page()
+ self.assertEqual(p.sayMyName(), 'testWebPage')
+
+ # Setting the same webpage should not incref the python obj
+ refCount = sys.getrefcount(p)
+ self.view.setPage(p)
+ self.assertEquals(sys.getrefcount(p), refCount)
+
+ # Changing the webpage obj should decref the old one
+ twp2 = testWebPage()
+ self.view.setPage(twp2)
+ self.assertEquals(sys.getrefcount(p), refCount - 1)
+
def load_finished(self, ok):
#Callback to check if load was successful
self.app.quit()