Fix bug#218 - TimedQApplication uses a singleton.
It's necessary to use a global TIMEOUT value, big enough to run
all the tests without killing the QApp.
Reviewer: Hugo Parente Lima <hugo.lima@openbossa.org>
Renato Araujo <renato.araujo@openbossa.org>
This commit is contained in:
parent
7fd722a38a
commit
17f9eed1ad
2 changed files with 14 additions and 7 deletions
|
|
@ -9,11 +9,15 @@ from PySide.QtNetwork import QNetworkAccessManager
|
||||||
|
|
||||||
from helper import adjust_filename, TimedQApplication
|
from helper import adjust_filename, TimedQApplication
|
||||||
|
|
||||||
|
#Define a global timeout because TimedQApplication uses a singleton!
|
||||||
|
#Use a value big enough to run all the tests.
|
||||||
|
TIMEOUT = 1000
|
||||||
|
|
||||||
class TestFindText(TimedQApplication):
|
class TestFindText(TimedQApplication):
|
||||||
'''Test cases for finding text'''
|
'''Test cases for finding text'''
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
TimedQApplication.setUp(self, timeout=250)
|
TimedQApplication.setUp(self, timeout=TIMEOUT)
|
||||||
self.page = QWebPage()
|
self.page = QWebPage()
|
||||||
QObject.connect(self.page, SIGNAL('loadFinished(bool)'),
|
QObject.connect(self.page, SIGNAL('loadFinished(bool)'),
|
||||||
self.load_finished)
|
self.load_finished)
|
||||||
|
|
@ -27,19 +31,22 @@ class TestFindText(TimedQApplication):
|
||||||
|
|
||||||
def testFindSelectText(self):
|
def testFindSelectText(self):
|
||||||
url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__))
|
url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__))
|
||||||
self.page.currentFrame().setUrl(url)
|
self.page.mainFrame().load(url)
|
||||||
self.app.exec_()
|
self.app.exec_()
|
||||||
self.assert_(self.called)
|
self.assert_(self.called)
|
||||||
|
|
||||||
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.assert_(self.page.findText('fox'))
|
|
||||||
self.assertEqual(self.page.selectedText(), 'fox')
|
|
||||||
self.app.quit()
|
|
||||||
if ok:
|
if ok:
|
||||||
self.called = True
|
self.called = True
|
||||||
|
self.assert_(self.page.findText('fox'))
|
||||||
|
self.assertEqual(self.page.selectedText(), 'fox')
|
||||||
|
self.app.quit()
|
||||||
|
|
||||||
class SetNetworkAccessManaterCase(TimedQApplication):
|
class SetNetworkAccessManagerCase(TimedQApplication):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
TimedQApplication.setUp(self, timeout=TIMEOUT)
|
||||||
|
|
||||||
def testSetNetworkAccessManager(self):
|
def testSetNetworkAccessManager(self):
|
||||||
page = QWebPage()
|
page = QWebPage()
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class TestLoadFinished(TimedQApplication):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
#Acquire resources
|
#Acquire resources
|
||||||
TimedQApplication.setUp(self, timeout=250)
|
TimedQApplication.setUp(self, timeout=1000)
|
||||||
self.view = QWebView()
|
self.view = QWebView()
|
||||||
QObject.connect(self.view, SIGNAL('loadFinished(bool)'),
|
QObject.connect(self.view, SIGNAL('loadFinished(bool)'),
|
||||||
self.load_finished)
|
self.load_finished)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue