diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-06-01 14:46:02 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:54:26 -0300 |
commit | 801efd40f37e8450f9d0e71fadf039a5bd7fe91a (patch) | |
tree | 32b2ced2de489197f810ccceb5d3b4ef712ae97d | |
parent | f957a6f42d2abf5b33bf2bd9b525731c313cc668 (diff) |
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.xml | 8 | ||||
-rw-r--r-- | tests/QtCore/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/QtCore/qabstractfileengine_test.py | 75 |
3 files changed, 83 insertions, 1 deletions
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 8795cf5f8..3183663bb 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"/> @@ -2284,6 +2284,12 @@ <modify-function signature="rmdir(const QString&, bool)const" allow-thread="yes" /> <modify-function signature="write(const char*, qint64)" allow-thread="yes" /> + <modify-function signature="beginEntryList(QFlags<QDir::Filter>,const QStringList&)"> + <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 365305fef..ab95ac3c1 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 000000000..457c5c530 --- /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() + |