summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-06-01 14:46:02 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2011-06-02 17:11:28 -0300
commit81272187412a2c6a3a13c95307c3f45d8f024562 (patch)
tree3f5744ac0342a524c1c9d53317a0e4dc177c8d20
parent046bccece9b01656489f1f83bf55a575bb461239 (diff)
downloadpyside-81272187412a2c6a3a13c95307c3f45d8f024562.tar.gz
pyside-81272187412a2c6a3a13c95307c3f45d8f024562.tar.xz
pyside-81272187412a2c6a3a13c95307c3f45d8f024562.zip
Removed the rejection of QAbstractFileEngine.beginEntryList.
Added an unit test. Reviewed by Hugo Parente <hugo.lima@openbossa.org> Reviewed by Renato Ara├║jo <renato.filho@openbossa.org>
-rw-r--r--PySide/QtCore/typesystem_core.xml8
-rw-r--r--tests/QtCore/CMakeLists.txt1
-rw-r--r--tests/QtCore/qabstractfileengine_test.py75
3 files changed, 83 insertions, 1 deletions
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml
index 5bb6922..7d46f23 100644
--- a/PySide/QtCore/typesystem_core.xml
+++ b/PySide/QtCore/typesystem_core.xml
@@ -231,7 +231,7 @@
<rejection class="QtConcurrent" enum-name="enum_1"/>
<rejection class="QAbstractEventDispatcher" function-name="filterEvent"/>
<rejection class="QAbstractEventDispatcher" function-name="setEventFilter"/>
- <rejection class="QAbstractFileEngine" function-name="beginEntryList"/>
+ <!-- Internal -->
<rejection class="QAbstractFileEngine" function-name="endEntryList"/>
<rejection class="QAbstractFileEngine" function-name="extension"/>
<rejection class="QCoreApplication" function-name="compressEvent"/>
@@ -2292,6 +2292,12 @@
<modify-function signature="rmdir(const QString&amp;, bool)const" allow-thread="yes" />
<modify-function signature="write(const char*, qint64)" allow-thread="yes" />
+ <modify-function signature="beginEntryList(QFlags&lt;QDir::Filter>,const QStringList&amp;)">
+ <modify-argument index="return">
+ <define-ownership class="native" owner="c++"/>
+ </modify-argument>
+ </modify-function>
+
<modify-function signature="unmap(uchar*)">
<modify-argument index="1">
<replace-type modified-type="PyBuffer"/>
diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt
index 365305f..ab95ac3 100644
--- a/tests/QtCore/CMakeLists.txt
+++ b/tests/QtCore/CMakeLists.txt
@@ -29,6 +29,7 @@ PYSIDE_TEST(missing_symbols_test.py)
PYSIDE_TEST(mockclass_test.py)
PYSIDE_TEST(python_conversion.py)
PYSIDE_TEST(qabs_test.py)
+PYSIDE_TEST(qabstractfileengine_test.py)
PYSIDE_TEST(qabstractitemmodel_test.py)
PYSIDE_TEST(qabstracttransition_test.py)
PYSIDE_TEST(qanimationgroup_test.py)
diff --git a/tests/QtCore/qabstractfileengine_test.py b/tests/QtCore/qabstractfileengine_test.py
new file mode 100644
index 0000000..457c5c5
--- /dev/null
+++ b/tests/QtCore/qabstractfileengine_test.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import unittest
+import os
+from PySide.QtCore import QAbstractFileEngineIterator, QAbstractFileEngine, QAbstractFileEngineHandler, QDir
+
+
+class TestFSIterator(QAbstractFileEngineIterator):
+ def __init__(self, parent, filters, filterNames):
+ QAbstractFileEngineIterator.__init__(self, filters, filterNames)
+ self.index = -1
+ self._list = ['.', '..']
+ if parent == '/bup':
+ self._list += ['A', 'B', 'C']
+
+ def next(self):
+ self.index += 1
+ return self.currentFileName()
+
+ def hasNext(self):
+ return (self.index + 1) < len(self._list)
+
+ def currentFileName(self):
+ if self.index < len(self._list):
+ return self._list[self.index]
+ return None
+
+
+class TestFS(QAbstractFileEngine):
+ def __init__(self, path):
+ QAbstractFileEngine.__init__(self)
+ self.path = path
+
+ def beginEntryList(self, filters, filterNames):
+ return TestFSIterator(self.path, filters, filterNames)
+
+ def fileFlags(self, _ = QAbstractFileEngine.FileInfoAll):
+ return QAbstractFileEngine.ExistsFlag\
+ |QAbstractFileEngine.ReadOwnerPerm\
+ |QAbstractFileEngine.ReadUserPerm\
+ |QAbstractFileEngine.ReadGroupPerm\
+ |QAbstractFileEngine.ReadOtherPerm\
+ |QAbstractFileEngine.DirectoryType
+
+ def fileName(self, path=QAbstractFileEngine.DefaultName):
+ if path == QAbstractFileEngine.DefaultName:
+ return self.path
+ return os.path.basename(self.path)
+
+ def setFileName(self, path):
+ self.path = path
+
+class TestFSHandler(QAbstractFileEngineHandler):
+ def __init__(self):
+ QAbstractFileEngineHandler.__init__(self)
+
+ def create(self, path):
+ if path.startswith('/bup'):
+ return TestFS(path)
+ return None
+
+class QAbstractFileEngineTest(unittest.TestCase):
+
+ def testBeginEntryList(self):
+ obj = TestFSHandler()
+ qdir = QDir('/bup')
+ for n1, n2 in zip(qdir.entryList(), ['.', '..', 'A', 'B', 'C']):
+ self.assertEqual(n1, n2)
+ self.assertEqual(len(qdir.entryList()), 5)
+
+
+if __name__ == '__main__':
+ unittest.main()
+