Fixed/implemented various QResources methods.
- data() is now exported and returns a Python read-only buffer object. - (un)registerResourceData now accept buffers as arguments, and respects zeroes in the middle of data. - Improved unit test.
This commit is contained in:
parent
b52148fd85
commit
7b4968abab
5 changed files with 3568 additions and 26 deletions
|
|
@ -4,27 +4,38 @@
|
|||
|
||||
import unittest
|
||||
import os
|
||||
from helper import adjust_filename
|
||||
from PySide.QtCore import QFile, QIODevice
|
||||
import resources_mc
|
||||
|
||||
class ResourcesUsage(unittest.TestCase):
|
||||
'''Test case for resources usage'''
|
||||
|
||||
def setUp(self):
|
||||
f = open(os.path.join(os.path.dirname(__file__), 'quoteEnUS.txt'))
|
||||
self.text = f.read()
|
||||
f.close()
|
||||
|
||||
def tearDown(self):
|
||||
self.text = None
|
||||
|
||||
def testPhrase(self):
|
||||
#Test loading of quote.txt resource
|
||||
f = open(adjust_filename('quoteEnUS.txt', __file__))
|
||||
orig = f.read()
|
||||
f.close()
|
||||
|
||||
f = QFile(':/quote.txt')
|
||||
f.open(QIODevice.ReadOnly|QIODevice.Text)
|
||||
content = f.readAll()
|
||||
copy = f.readAll()
|
||||
f.close()
|
||||
self.assertEqual(self.text, content)
|
||||
self.assertEqual(orig, copy)
|
||||
|
||||
def testImage(self):
|
||||
#Test loading of sample.png resource
|
||||
f = open(adjust_filename('sample.png', __file__))
|
||||
orig = f.read()
|
||||
f.close()
|
||||
|
||||
f = QFile(':/sample.png')
|
||||
f.open(QIODevice.ReadOnly)
|
||||
copy = f.readAll()
|
||||
f.close()
|
||||
self.assertEqual(len(orig), len(copy))
|
||||
self.assertEqual(orig, copy)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file alias="quote.txt">quoteEnUS.txt</file>
|
||||
<file alias="sample.png">sample.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
BIN
tests/QtCore/sample.png
Normal file
BIN
tests/QtCore/sample.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 55 KiB |
Loading…
Add table
Add a link
Reference in a new issue