summaryrefslogtreecommitdiffstats
path: root/tests/auto/qfileinfo
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2010-08-31 07:56:27 (GMT)
committerJoão Abecasis <joao.abecasis@nokia.com>2010-08-31 16:27:54 (GMT)
commitc14c0a61bbd8466b00f5600707bc0aedbbf260af (patch)
tree62cc01385d071bd63509955babdd0911603728e6 /tests/auto/qfileinfo
parent7a9f84eb0563355aab76c0b56db44382c516cf35 (diff)
downloadQt-c14c0a61bbd8466b00f5600707bc0aedbbf260af.zip
Qt-c14c0a61bbd8466b00f5600707bc0aedbbf260af.tar.gz
Qt-c14c0a61bbd8466b00f5600707bc0aedbbf260af.tar.bz2
QDir and QFileInfo shouldn't lose properties when detaching
For QFileInfo, the caching state was being lost on the different setFile overloads. QDir::cd and ::makeAbsolute were losing filters and sorting flags. QDir issues were introduced with these patches: "Simplify QDir::cd" "QDir::makeAbsolute could self-destruct on failure" Reviewed-by: Prasanth Ullattil
Diffstat (limited to 'tests/auto/qfileinfo')
-rw-r--r--tests/auto/qfileinfo/tst_qfileinfo.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp
index 32aa671..7659a75 100644
--- a/tests/auto/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp
@@ -181,6 +181,8 @@ private slots:
void equalOperator() const;
void equalOperatorWithDifferentSlashes() const;
void notEqualOperator() const;
+
+ void detachingOperations();
};
tst_QFileInfo::tst_QFileInfo()
@@ -1545,5 +1547,51 @@ void tst_QFileInfo::notEqualOperator() const
QVERIFY(QFileInfo() != QFileInfo());
}
+void tst_QFileInfo::detachingOperations()
+{
+ QFileInfo info1;
+ QVERIFY(info1.caching());
+ info1.setCaching(false);
+
+ {
+ QFileInfo info2 = info1;
+
+ QVERIFY(!info1.caching());
+ QVERIFY(!info2.caching());
+
+ info2.setCaching(true);
+ QVERIFY(info2.caching());
+
+ info1.setFile("foo");
+ QVERIFY(!info1.caching());
+ }
+
+ {
+ QFile file("foo");
+ info1.setFile(file);
+ QVERIFY(!info1.caching());
+ }
+
+ info1.setFile(QDir(), "foo");
+ QVERIFY(!info1.caching());
+
+ {
+ QFileInfo info3;
+ QVERIFY(info3.caching());
+
+ info3 = info1;
+ QVERIFY(!info3.caching());
+ }
+
+ info1.refresh();
+ QVERIFY(!info1.caching());
+
+ QVERIFY(info1.makeAbsolute());
+ QVERIFY(!info1.caching());
+
+ info1.detach();
+ QVERIFY(!info1.caching());
+}
+
QTEST_MAIN(tst_QFileInfo)
#include "tst_qfileinfo.moc"