summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-09-08 18:05:05 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-09-08 18:05:05 (GMT)
commitd030e69cbabfcae81054e5b8c893b28b2d9de38b (patch)
treec60003ca1b12e5179c47eeb2ee48994d95fde20d /tests
parent526705430be6371166464689e970752a5ce41ed6 (diff)
parent4c0e59e6ad6b697a28f7c57540fb2eb0042d04d0 (diff)
downloadQt-d030e69cbabfcae81054e5b8c893b28b2d9de38b.zip
Qt-d030e69cbabfcae81054e5b8c893b28b2d9de38b.tar.gz
Qt-d030e69cbabfcae81054e5b8c893b28b2d9de38b.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (27 commits) Work around a compiler bug on 64-bit. Fix handling of braces/no-braces in QUrl::host / setHost. Changes (and minor corrections) to QByteArray documentation. QtWebKit: Update tag files to match the same content on qtwebkit.git QtWebKit: Downstream patch 2 fixing a crash on MSVC 64bit. QtWebKit: Downstream patch 1 fixing a crash on MSVC 64bit. uic: Fix compile breakage in case QT_NO_QT3_SUPPORT. uic: Improve messages. Tools (uic/rcc): Improve warning messages. QDir: Removed checks for existance of fileEngine QDir and QFileInfo shouldn't lose properties when detaching Another bug-o introduced in fixing QDirPrivate refactoring Reverting QDir::detach introduced earlier QFileInfo: Prepare for engine-less implementation Removed QFileInfoPrivate::initFileEngine Simplify QDir::cd QDir::makeAbsolute could self-destruct on failure QDir::operator= simplification QDirPrivate refactoring QDirPrivate refactoring ...
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qdir/tst_qdir.cpp99
-rw-r--r--tests/auto/qfileinfo/tst_qfileinfo.cpp65
-rw-r--r--tests/auto/qurl/tst_qurl.cpp6
3 files changed, 161 insertions, 9 deletions
diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp
index c8c835f..fb83a5a 100644
--- a/tests/auto/qdir/tst_qdir.cpp
+++ b/tests/auto/qdir/tst_qdir.cpp
@@ -167,6 +167,8 @@ private slots:
void longFileName();
void updateFileLists();
+
+ void detachingOperations();
};
// Testing get/set functions
@@ -1541,6 +1543,103 @@ void tst_QDir::updateFileLists()
QCOMPARE(dir.entryList(), QStringList() << "sub-dir1" << "sub-dir2" << "file1.txt");
}
+void tst_QDir::detachingOperations()
+{
+ QString const defaultPath(".");
+ QStringList const defaultNameFilters = QStringList("*");
+ QDir::SortFlags const defaultSorting = QDir::Name | QDir::IgnoreCase;
+ QDir::Filters const defaultFilter = QDir::AllEntries;
+
+ QString const path1("..");
+ QString const path2("./foo");
+ QStringList const nameFilters = QStringList(QString("*.txt"));
+ QDir::SortFlags const sorting = QDir::Name | QDir::DirsLast | QDir::Reversed;
+ QDir::Filters const filter = QDir::Writable;
+
+ QDir dir1;
+
+ QCOMPARE(dir1.path(), defaultPath);
+ QCOMPARE(dir1.filter(), defaultFilter);
+ QCOMPARE(dir1.nameFilters(), defaultNameFilters);
+ QCOMPARE(dir1.sorting(), defaultSorting);
+
+ dir1.setPath(path1);
+ QCOMPARE(dir1.path(), path1);
+ QCOMPARE(dir1.filter(), defaultFilter);
+ QCOMPARE(dir1.nameFilters(), defaultNameFilters);
+ QCOMPARE(dir1.sorting(), defaultSorting);
+
+ dir1.setFilter(filter);
+ QCOMPARE(dir1.path(), path1);
+ QCOMPARE(dir1.filter(), filter);
+ QCOMPARE(dir1.nameFilters(), defaultNameFilters);
+ QCOMPARE(dir1.sorting(), defaultSorting);
+
+ dir1.setNameFilters(nameFilters);
+ QCOMPARE(dir1.path(), path1);
+ QCOMPARE(dir1.filter(), filter);
+ QCOMPARE(dir1.nameFilters(), nameFilters);
+ QCOMPARE(dir1.sorting(), defaultSorting);
+
+ dir1.setSorting(sorting);
+ QCOMPARE(dir1.path(), path1);
+ QCOMPARE(dir1.filter(), filter);
+ QCOMPARE(dir1.nameFilters(), nameFilters);
+ QCOMPARE(dir1.sorting(), sorting);
+
+ dir1.setPath(path2);
+ QCOMPARE(dir1.path(), path2);
+ QCOMPARE(dir1.filter(), filter);
+ QCOMPARE(dir1.nameFilters(), nameFilters);
+ QCOMPARE(dir1.sorting(), sorting);
+
+ {
+ QDir dir2(dir1);
+ QCOMPARE(dir2.path(), path2);
+ QCOMPARE(dir2.filter(), filter);
+ QCOMPARE(dir2.nameFilters(), nameFilters);
+ QCOMPARE(dir2.sorting(), sorting);
+ }
+
+ {
+ QDir dir2;
+ QCOMPARE(dir2.path(), defaultPath);
+ QCOMPARE(dir2.filter(), defaultFilter);
+ QCOMPARE(dir2.nameFilters(), defaultNameFilters);
+ QCOMPARE(dir2.sorting(), defaultSorting);
+
+ dir2 = dir1;
+ QCOMPARE(dir2.path(), path2);
+ QCOMPARE(dir2.filter(), filter);
+ QCOMPARE(dir2.nameFilters(), nameFilters);
+ QCOMPARE(dir2.sorting(), sorting);
+
+ dir2 = path1;
+ QCOMPARE(dir2.path(), path1);
+ QCOMPARE(dir2.filter(), filter);
+ QCOMPARE(dir2.nameFilters(), nameFilters);
+ QCOMPARE(dir2.sorting(), sorting);
+ }
+
+ dir1.refresh();
+ QCOMPARE(dir1.path(), path2);
+ QCOMPARE(dir1.filter(), filter);
+ QCOMPARE(dir1.nameFilters(), nameFilters);
+ QCOMPARE(dir1.sorting(), sorting);
+
+ QString const currentPath = QDir::currentPath();
+ QVERIFY(dir1.cd(currentPath));
+ QCOMPARE(dir1.path(), currentPath);
+ QCOMPARE(dir1.filter(), filter);
+ QCOMPARE(dir1.nameFilters(), nameFilters);
+ QCOMPARE(dir1.sorting(), sorting);
+
+ QVERIFY(dir1.cdUp());
+ QCOMPARE(dir1.filter(), filter);
+ QCOMPARE(dir1.nameFilters(), nameFilters);
+ QCOMPARE(dir1.sorting(), sorting);
+}
+
QTEST_MAIN(tst_QDir)
#include "tst_qdir.moc"
diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp
index 93b1891..208110a 100644
--- a/tests/auto/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp
@@ -172,6 +172,8 @@ private slots:
void equalOperator() const;
void equalOperatorWithDifferentSlashes() const;
void notEqualOperator() const;
+
+ void detachingOperations();
};
tst_QFileInfo::tst_QFileInfo()
@@ -228,13 +230,13 @@ void tst_QFileInfo::copy()
QFileInfo info2(info);
QFileInfoPrivate *privateInfo = getPrivate(info);
QFileInfoPrivate *privateInfo2 = getPrivate(info2);
- QCOMPARE(privateInfo->data, privateInfo2->data);
+ QCOMPARE(privateInfo, privateInfo2);
//operator =
QFileInfo info3 = info;
QFileInfoPrivate *privateInfo3 = getPrivate(info3);
- QCOMPARE(privateInfo->data, privateInfo3->data);
- QCOMPARE(privateInfo2->data, privateInfo3->data);
+ QCOMPARE(privateInfo, privateInfo3);
+ QCOMPARE(privateInfo2, privateInfo3);
//refreshing info3 will detach it
QFile file(info.absoluteFilePath());
@@ -256,9 +258,10 @@ void tst_QFileInfo::copy()
QTest::qWait(5000);
#endif
info3.refresh();
- QVERIFY(privateInfo->data != privateInfo3->data);
- QVERIFY(privateInfo2->data != privateInfo3->data);
- QCOMPARE(privateInfo->data, privateInfo2->data);
+ privateInfo3 = getPrivate(info3);
+ QVERIFY(privateInfo != privateInfo3);
+ QVERIFY(privateInfo2 != privateInfo3);
+ QCOMPARE(privateInfo, privateInfo2);
}
void tst_QFileInfo::isFile_data()
@@ -1182,8 +1185,8 @@ void tst_QFileInfo::isLocalFs()
QFileInfo info(path);
QFileInfoPrivate *privateInfo = getPrivate(info);
- QVERIFY(privateInfo->data->fileEngine);
- QCOMPARE(bool(privateInfo->data->fileEngine->fileFlags(QAbstractFileEngine::LocalDiskFlag)
+ QVERIFY(privateInfo->fileEngine);
+ QCOMPARE(bool(privateInfo->fileEngine->fileFlags(QAbstractFileEngine::LocalDiskFlag)
& QAbstractFileEngine::LocalDiskFlag), isLocalFs);
}
@@ -1376,5 +1379,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"
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index 370bd13..b5236e5 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -2266,7 +2266,9 @@ void tst_QUrl::ipv6()
QCOMPARE(url.isValid(), isValid);
if (url.isValid()) {
- QCOMPARE(url.toString(), ipv6Auth);
+ QCOMPARE(url.toString(), ipv6Auth);
+ url.setHost(url.host());
+ QCOMPARE(url.toString(), ipv6Auth);
}
};
@@ -2290,6 +2292,8 @@ void tst_QUrl::ipv6_2()
QUrl url(input);
QCOMPARE(url.toString(), output);
+ url.setHost(url.host());
+ QCOMPARE(url.toString(), output);
}
void tst_QUrl::moreIpv6()