From 3d6cbe3409d52e5ca63b8d04261b8fd531d89c98 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 29 Jun 2017 14:53:05 -0700 Subject: Long live QTemporaryFileName! So we can use it in QTemporaryFile, QTemporaryDir and QFile::rename() [ChangeLog][QtCore][QTemporaryDir] The class now supports the "XXXXXX" replacement token anywhere in the template, not just at the end. This behavior is similar to what QTemporaryFile supports. Change-Id: I1eba2b016de74620bfc8fffd14ccb645729de170 Reviewed-by: Lars Knoll --- .../corelib/io/qtemporarydir/tst_qtemporarydir.cpp | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp') diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index 4bed8d0fd6..fcd9133099 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -148,25 +148,24 @@ void tst_QTemporaryDir::fileTemplate_data() { QTest::addColumn("constructorTemplate"); QTest::addColumn("prefix"); + QTest::addColumn("suffix"); + + QTest::newRow("default") << "" << "tst_qtemporarydir-" << ""; - QTest::newRow("constructor default") << "" << "tst_qtemporarydir-"; - - QTest::newRow("constructor with xxx sufix") << "qt_XXXXXXxxx" << "qt_XXXXXXxxx"; - QTest::newRow("constructor with xXx sufix") << "qt_XXXXXXxXx" << "qt_XXXXXXxXx"; - QTest::newRow("constructor with no suffix") << "qt_XXXXXX" << "qt_"; - QTest::newRow("constructor with >6 X's, no suffix") << "qt_XXXXXXXXXX" << "qt_"; - // When more than 6 X are present at the end, linux and windows will only replace the last 6, - // while Mac OS will actually replace all of them so we can only expect "qt_" (and check isValid). - QTest::newRow("constructor with XXXX suffix") << "qt_XXXXXX_XXXX" << "qt_"; - QTest::newRow("constructor with XXXX prefix") << "qt_XXXX" << "qt_"; - QTest::newRow("constructor with XXXXX prefix") << "qt_XXXXX" << "qt_"; + QTest::newRow("xxx-suffix") << "qt_XXXXXXxxx" << "qt_" << "xxx"; + QTest::newRow("xXx-suffix") << "qt_XXXXXXxXx" << "qt_" << "xXx"; + QTest::newRow("no-suffix") << "qt_XXXXXX" << "qt_" << ""; + QTest::newRow("10X") << "qt_XXXXXXXXXX" << "qt_" << ""; + QTest::newRow("4Xsuffix") << "qt_XXXXXX_XXXX" << "qt_" << "_XXXX"; + QTest::newRow("4Xprefix") << "qt_XXXX" << "qt_XXXX" << ""; + QTest::newRow("5Xprefix") << "qt_XXXXX" << "qt_XXXXX" << ""; if (canHandleUnicodeFileNames()) { // Test Umlauts (contained in Latin1) QString prefix = "qt_" + umlautTestText(); - QTest::newRow("Umlauts") << (prefix + "XXXXXX") << prefix; - // Test Chinese + QTest::newRow("Umlauts") << (prefix + "XXXXXX") << prefix << ""; + // test non-Latin1 prefix = "qt_" + hanTestText(); - QTest::newRow("Chinese characters") << (prefix + "XXXXXX") << prefix; + QTest::newRow("Chinese") << (prefix + "XXXXXX" + umlautTestText()) << prefix << umlautTestText(); } } @@ -174,14 +173,17 @@ void tst_QTemporaryDir::fileTemplate() { QFETCH(QString, constructorTemplate); QFETCH(QString, prefix); + QFETCH(QString, suffix); QTemporaryDir tempDir(constructorTemplate); QVERIFY(tempDir.isValid()); QString dirName = QDir(tempDir.path()).dirName(); - if (prefix.length()) + if (prefix.length()) { QCOMPARE(dirName.left(prefix.length()), prefix); + QCOMPARE(dirName.right(suffix.length()), suffix); + } } -- cgit v1.2.3