Fix bug#254 - "QWebView.setPage() does not seem to work"
Reviewer: Lauro Moura <lauro.neto@openbossa.org>
Renato Araújo <renato.filho@openbossa.org>
This commit is contained in:
parent
067b49c738
commit
cbf12bc3a0
2 changed files with 29 additions and 2 deletions
|
|
@ -49,7 +49,12 @@
|
||||||
<object-type name="QWebView">
|
<object-type name="QWebView">
|
||||||
<modify-function signature="setPage(QWebPage*)">
|
<modify-function signature="setPage(QWebPage*)">
|
||||||
<modify-argument index="1">
|
<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-argument>
|
||||||
</modify-function>
|
</modify-function>
|
||||||
<modify-function signature="print(QPrinter*)const" rename="print_" />
|
<modify-function signature="print(QPrinter*)const" rename="print_" />
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,18 @@
|
||||||
'''Test cases for QWebView'''
|
'''Test cases for QWebView'''
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
import sys
|
||||||
|
|
||||||
from PySide.QtCore import QObject, SIGNAL, QUrl
|
from PySide.QtCore import QObject, SIGNAL, QUrl
|
||||||
from PySide.QtWebKit import QWebView
|
from PySide.QtWebKit import *
|
||||||
|
|
||||||
from helper import adjust_filename, TimedQApplication
|
from helper import adjust_filename, TimedQApplication
|
||||||
|
|
||||||
|
|
||||||
|
class testWebPage(QWebPage):
|
||||||
|
def sayMyName(self):
|
||||||
|
return 'testWebPage'
|
||||||
|
|
||||||
class TestLoadFinished(TimedQApplication):
|
class TestLoadFinished(TimedQApplication):
|
||||||
'''Test case for signal QWebView.loadFinished(bool)'''
|
'''Test case for signal QWebView.loadFinished(bool)'''
|
||||||
|
|
||||||
|
|
@ -33,6 +38,23 @@ class TestLoadFinished(TimedQApplication):
|
||||||
|
|
||||||
self.assert_(self.called)
|
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):
|
def load_finished(self, ok):
|
||||||
#Callback to check if load was successful
|
#Callback to check if load was successful
|
||||||
self.app.quit()
|
self.app.quit()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue