Added all original pyside unit tests to the shiboken version.
This commit is contained in:
parent
aa12538d63
commit
9af36fbb64
160 changed files with 6616 additions and 12 deletions
48
tests/qtnetwork/http_test.py
Normal file
48
tests/qtnetwork/http_test.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
'''Test cases for QHttp'''
|
||||
|
||||
import unittest
|
||||
|
||||
from PySide.QtCore import *
|
||||
from PySide.QtNetwork import *
|
||||
|
||||
from helper import UsesQApplication
|
||||
|
||||
class HttpSignalsCase(UsesQApplication):
|
||||
'''Test case for launching QHttp signals'''
|
||||
|
||||
def setUp(self):
|
||||
super(HttpSignalsCase, self).setUp()
|
||||
|
||||
self.http = QHttp()
|
||||
self.url = QUrl('http://www.google.com')
|
||||
self.timer = QTimer.singleShot(250, self.app.quit)
|
||||
|
||||
def tearDown(self):
|
||||
del self.http
|
||||
super(HttpSignalsCase, self).tearDown()
|
||||
|
||||
def callback(self, ident):
|
||||
self.called = True
|
||||
|
||||
def testDefaultArgs(self):
|
||||
#QHttp signal requestStarted signal
|
||||
# @bug 114
|
||||
QObject.connect(self.http, SIGNAL('requestStarted(int)'), self.callback)
|
||||
self.http.get(self.url.path())
|
||||
|
||||
self.app.exec_()
|
||||
self.assert_(self.called)
|
||||
|
||||
class testHttp(UsesQApplication):
|
||||
def testRead(self):
|
||||
header = QHttpRequestHeader("GET", QString(QUrl.toPercentEncoding("/index.html")))
|
||||
header.setValue("Host", "qtsoftware.com");
|
||||
http = QHttp()
|
||||
http.setHost("qtsoftware.com")
|
||||
http.request(header)
|
||||
data = http.read(100)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
25
tests/qtnetwork/tcpserver_test.py
Normal file
25
tests/qtnetwork/tcpserver_test.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
'''Test cases for QTCPServer'''
|
||||
|
||||
import unittest
|
||||
|
||||
from PySide.QtNetwork import QTcpServer
|
||||
|
||||
class ListenDefaultArgsCase(unittest.TestCase):
|
||||
'''Test case for TcpServer.listen with default args'''
|
||||
|
||||
def setUp(self):
|
||||
#Acquire resources
|
||||
self.server = QTcpServer()
|
||||
|
||||
def tearDown(self):
|
||||
#Release resources
|
||||
del self.server
|
||||
|
||||
def testDefaultArgs(self):
|
||||
# @bug 108
|
||||
#Default arguments for QTcpServer.listen
|
||||
self.server.listen()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
54
tests/qtnetwork/udpsocket_test.py
Normal file
54
tests/qtnetwork/udpsocket_test.py
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
|
||||
'''Test cases for QUdpSocket'''
|
||||
|
||||
import unittest
|
||||
|
||||
from PySide.QtCore import QUrl, QObject, SIGNAL, QCoreApplication, QTimer
|
||||
from PySide.QtNetwork import QUdpSocket, QHostAddress
|
||||
|
||||
class HttpSignalsCase(unittest.TestCase):
|
||||
'''Test case for bug #124 - readDatagram signature
|
||||
|
||||
QUdpSocket.readDatagram must return a tuple with the datagram, host and
|
||||
port, while receiving only the max payload size.'''
|
||||
|
||||
def setUp(self):
|
||||
#Acquire resources
|
||||
self.app = QCoreApplication([])
|
||||
self.socket = QUdpSocket()
|
||||
self.socket.bind(45454)
|
||||
self.server = QUdpSocket()
|
||||
self.timer = QTimer.singleShot(1000, self.app.quit)
|
||||
self.a = QTimer.singleShot(100, self.broadcast)
|
||||
#self.a = QTimer()
|
||||
#self.a.setInterval(100)
|
||||
#QObject.connect(self.a, SIGNAL('timeout()'), self.broadcast)
|
||||
#self.a.start()
|
||||
|
||||
def tearDown(self):
|
||||
#Release resources
|
||||
del self.socket
|
||||
del self.server
|
||||
del self.app
|
||||
|
||||
def broadcast(self):
|
||||
addr = QHostAddress(QHostAddress.Broadcast)
|
||||
self.server.writeDatagram('datagram', addr, 45454)
|
||||
|
||||
def callback(self):
|
||||
while self.socket.hasPendingDatagrams():
|
||||
datagram, host, port = self.socket.readDatagram(
|
||||
self.socket.pendingDatagramSize())
|
||||
self.called = True
|
||||
self.app.quit()
|
||||
|
||||
def testDefaultArgs(self):
|
||||
#QUdpSocket.readDatagram pythonic return
|
||||
# @bug 124
|
||||
QObject.connect(self.socket, SIGNAL('readyRead()'), self.callback)
|
||||
self.app.exec_()
|
||||
|
||||
self.assert_(self.called)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue