aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-04-24 12:47:35 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-04-24 11:06:05 +0000
commit1b0ba0e96666e66d16ee5c83062a118605aaeadc (patch)
tree3a688987bda7c8d7e75734ed18cd4780cd7c69fb
parente212817ebacab0ead54dcb76f83ac59cda8295df (diff)
QtCore: Add some missing classes for I/O
Add QStorageInfo, QSaveFile and QTemporaryDir. Change-Id: Ice72ed52c86f9d51ca5e60ac988abc3320a51f13 Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--PySide2/QtCore/CMakeLists.txt3
-rw-r--r--PySide2/QtCore/typesystem_core_common.xml3
-rw-r--r--tests/QtCore/CMakeLists.txt1
-rw-r--r--tests/QtCore/qfile_test.py11
-rw-r--r--tests/QtCore/qstorageinfo_test.py43
5 files changed, 60 insertions, 1 deletions
diff --git a/PySide2/QtCore/CMakeLists.txt b/PySide2/QtCore/CMakeLists.txt
index 77e304c3..74f486f2 100644
--- a/PySide2/QtCore/CMakeLists.txt
+++ b/PySide2/QtCore/CMakeLists.txt
@@ -101,6 +101,7 @@ ${QtCore_GEN_DIR}/qrectf_wrapper.cpp
${QtCore_GEN_DIR}/qregexp_wrapper.cpp
${QtCore_GEN_DIR}/qresource_wrapper.cpp
${QtCore_GEN_DIR}/qrunnable_wrapper.cpp
+${QtCore_GEN_DIR}/qsavefile_wrapper.cpp
${QtCore_GEN_DIR}/qsemaphore_wrapper.cpp
${QtCore_GEN_DIR}/qsequentialanimationgroup_wrapper.cpp
${QtCore_GEN_DIR}/qsettings_wrapper.cpp
@@ -115,9 +116,11 @@ ${QtCore_GEN_DIR}/qstandardpaths_wrapper.cpp
${QtCore_GEN_DIR}/qstatemachine_signalevent_wrapper.cpp
${QtCore_GEN_DIR}/qstatemachine_wrappedevent_wrapper.cpp
${QtCore_GEN_DIR}/qstatemachine_wrapper.cpp
+${QtCore_GEN_DIR}/qstorageinfo_wrapper.cpp
${QtCore_GEN_DIR}/qsysinfo_wrapper.cpp
${QtCore_GEN_DIR}/qsystemsemaphore_wrapper.cpp
${QtCore_GEN_DIR}/qt_wrapper.cpp
+${QtCore_GEN_DIR}/qtemporarydir_wrapper.cpp
${QtCore_GEN_DIR}/qtemporaryfile_wrapper.cpp
${QtCore_GEN_DIR}/qtextboundaryfinder_wrapper.cpp
${QtCore_GEN_DIR}/qtextcodec_converterstate_wrapper.cpp
diff --git a/PySide2/QtCore/typesystem_core_common.xml b/PySide2/QtCore/typesystem_core_common.xml
index c0477cc5..f7960647 100644
--- a/PySide2/QtCore/typesystem_core_common.xml
+++ b/PySide2/QtCore/typesystem_core_common.xml
@@ -1939,6 +1939,7 @@
</inject-code>
</add-function>
</value-type>
+ <value-type name="QStorageInfo"/>
<!-- QReadWriteLock does not have a copy ctor! -->
<object-type name="QReadWriteLock">
<enum-type name="RecursionMode"/>
@@ -2826,6 +2827,7 @@
<modify-function signature="rename(const QString&amp;)" allow-thread="yes"/>
<modify-function signature="rename(const QString&amp;, const QString&amp;)" allow-thread="yes"/>
</object-type>
+ <object-type name="QSaveFile"/>
<object-type name="QFileSelector" />
<object-type name="QIODevice">
@@ -2986,6 +2988,7 @@
</extra-includes>
<modify-function signature="createLocalFile(const QString&amp;)" allow-thread="yes"/>
</object-type>
+ <object-type name="QTemporaryDir"/>
<object-type name="QMimeData">
<extra-includes>
<include file-name="QStringList" location="global"/>
diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt
index 5771e10f..436af3da 100644
--- a/tests/QtCore/CMakeLists.txt
+++ b/tests/QtCore/CMakeLists.txt
@@ -92,6 +92,7 @@ PYSIDE_TEST(qsrand_test.py)
PYSIDE_TEST(qstandardpaths_test.py)
PYSIDE_TEST(qstatemachine_test.py)
PYSIDE_TEST(qstate_test.py)
+PYSIDE_TEST(qstorageinfo_test.py)
PYSIDE_TEST(qstring_test.py)
PYSIDE_TEST(qsysinfo_test.py)
PYSIDE_TEST(qtext_codec_test.py)
diff --git a/tests/QtCore/qfile_test.py b/tests/QtCore/qfile_test.py
index 954f649c..b58e9b6a 100644
--- a/tests/QtCore/qfile_test.py
+++ b/tests/QtCore/qfile_test.py
@@ -33,7 +33,7 @@ import tempfile
import sys
import py3kcompat as py3k
-from PySide2.QtCore import QFile, QIODevice
+from PySide2.QtCore import QDir, QFile, QIODevice, QSaveFile, QTemporaryDir
class GetCharTest(unittest.TestCase):
'''Test case for QIODevice.getChar in QFile'''
@@ -75,5 +75,14 @@ class GetCharTest(unittest.TestCase):
obj.unmap(memory)
obj.close()
+ def testQSaveFile(self):
+ dir = QTemporaryDir(QDir.tempPath() + "/XXXXXX.dir")
+ self.assertTrue(dir.isValid())
+ saveFile = QSaveFile(dir.path() + "/test.dat")
+ self.assertTrue(saveFile.open(QIODevice.WriteOnly))
+ saveFile.write("Test")
+ self.assertTrue(saveFile.commit())
+ self.assertTrue(os.path.exists(QDir.toNativeSeparators(saveFile.fileName())))
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/QtCore/qstorageinfo_test.py b/tests/QtCore/qstorageinfo_test.py
new file mode 100644
index 00000000..f1b90bb6
--- /dev/null
+++ b/tests/QtCore/qstorageinfo_test.py
@@ -0,0 +1,43 @@
+#!/usr/bin/python
+
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for QStorageInfo'''
+
+import unittest
+
+from PySide2.QtCore import QStorageInfo
+
+class QandardPathsTest(unittest.TestCase):
+ def testQStorageInfo(self):
+ for v in QStorageInfo.mountedVolumes():
+ print(v.name(), v.rootPath(), v.device())
+
+if __name__ == '__main__':
+ unittest.main()