summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-10 14:10:41 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-10 14:10:41 (GMT)
commitf01efd0b49be074d9bc5a963b6d353b9eddf365a (patch)
tree641fafc790577218840a72c653e55b1e1033999b /tests
parent14f72183fbe1c7fad7c5434b2af032cc51436f5e (diff)
parent188a4ab62c99dcb113cad1833a0701d84a886e65 (diff)
downloadQt-f01efd0b49be074d9bc5a963b6d353b9eddf365a.zip
Qt-f01efd0b49be074d9bc5a963b6d353b9eddf365a.tar.gz
Qt-f01efd0b49be074d9bc5a963b6d353b9eddf365a.tar.bz2
Merge commit 'qt-mainline/master' into master-recursivepaint
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qfileinfo/tst_qfileinfo.cpp56
-rw-r--r--tests/auto/qlistwidget/tst_qlistwidget.cpp39
2 files changed, 83 insertions, 12 deletions
diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp
index 3d7e6f8..cccdd64 100644
--- a/tests/auto/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp
@@ -61,6 +61,7 @@
#include <qdebug.h>
#include "../network-settings.h"
+#include <private/qfileinfo_p.h>
//TESTED_CLASS=
//TESTED_FILES=
@@ -75,6 +76,9 @@ public:
private slots:
void getSetCheck();
+
+ void copy();
+
void isFile_data();
void isFile();
@@ -178,6 +182,58 @@ void tst_QFileInfo::getSetCheck()
QCOMPARE(true, obj1.caching());
}
+static QFileInfoPrivate* getPrivate(QFileInfo &info)
+{
+ return (*reinterpret_cast<QFileInfoPrivate**>(&info));
+}
+
+void tst_QFileInfo::copy()
+{
+ QTemporaryFile *t;
+ t = new QTemporaryFile;
+ t->open();
+ QFileInfo info(t->fileName());
+ QVERIFY(info.exists());
+
+ //copy constructor
+ QFileInfo info2(info);
+ QFileInfoPrivate *privateInfo = getPrivate(info);
+ QFileInfoPrivate *privateInfo2 = getPrivate(info2);
+ QCOMPARE(privateInfo->data, privateInfo2->data);
+
+ //operator =
+ QFileInfo info3 = info;
+ QFileInfoPrivate *privateInfo3 = getPrivate(info3);
+ QCOMPARE(privateInfo->data, privateInfo3->data);
+ QCOMPARE(privateInfo2->data, privateInfo3->data);
+
+ //refreshing info3 will detach it
+ QFile file(info.absoluteFilePath());
+ QVERIFY(file.open(QFile::WriteOnly));
+ QCOMPARE(file.write("JAJAJAA"), qint64(7));
+ file.flush();
+
+ QTest::qWait(250);
+#if defined(Q_OS_WIN) || defined(Q_OS_WINCE)
+ if (QSysInfo::windowsVersion() & QSysInfo::WV_VISTA ||
+ QSysInfo::windowsVersion() & QSysInfo::WV_CE_based)
+ file.close();
+#endif
+#if defined(Q_OS_WINCE)
+ // On Windows CE we need to close the file.
+ // Otherwise the content will be cached and not
+ // flushed to the storage, although we flushed it
+ // manually!!! CE has interim cache, we cannot influence.
+ QTest::qWait(5000);
+#endif
+ info3.refresh();
+ QVERIFY(privateInfo->data != privateInfo3->data);
+ QVERIFY(privateInfo2->data != privateInfo3->data);
+ QCOMPARE(privateInfo->data, privateInfo2->data);
+
+
+}
+
tst_QFileInfo::tst_QFileInfo()
{
}
diff --git a/tests/auto/qlistwidget/tst_qlistwidget.cpp b/tests/auto/qlistwidget/tst_qlistwidget.cpp
index 8d15aa4..8468cf3 100644
--- a/tests/auto/qlistwidget/tst_qlistwidget.cpp
+++ b/tests/auto/qlistwidget/tst_qlistwidget.cpp
@@ -883,31 +883,46 @@ void tst_QListWidget::itemStreaming()
void tst_QListWidget::sortItems_data()
{
QTest::addColumn<int>("order");
- QTest::addColumn<QStringList>("initialList");
- QTest::addColumn<QStringList>("expectedList");
+ QTest::addColumn<QVariantList>("initialList");
+ QTest::addColumn<QVariantList>("expectedList");
QTest::addColumn<IntList>("expectedRows");
- QTest::newRow("ascending order")
+ QTest::newRow("ascending strings")
<< static_cast<int>(Qt::AscendingOrder)
- << (QStringList() << "c" << "d" << "a" << "b")
- << (QStringList() << "a" << "b" << "c" << "d")
+ << (QVariantList() << QString("c") << QString("d") << QString("a") << QString("b"))
+ << (QVariantList() << QString("a") << QString("b") << QString("c") << QString("d"))
<< (IntList() << 2 << 3 << 0 << 1);
- QTest::newRow("descending order")
+ QTest::newRow("descending strings")
<< static_cast<int>(Qt::DescendingOrder)
- << (QStringList() << "c" << "d" << "a" << "b")
- << (QStringList() << "d" << "c" << "b" << "a")
+ << (QVariantList() << QString("c") << QString("d") << QString("a") << QString("b"))
+ << (QVariantList() << QString("d") << QString("c") << QString("b") << QString("a"))
<< (IntList() << 1 << 0 << 3 << 2);
+
+ QTest::newRow("ascending numbers")
+ << static_cast<int>(Qt::AscendingOrder)
+ << (QVariantList() << 1 << 11 << 2 << 22)
+ << (QVariantList() << 1 << 2 << 11 << 22)
+ << (IntList() << 0 << 2 << 1 << 3);
+
+ QTest::newRow("descending numbers")
+ << static_cast<int>(Qt::DescendingOrder)
+ << (QVariantList() << 1 << 11 << 2 << 22)
+ << (QVariantList() << 22 << 11 << 2 << 1)
+ << (IntList() << 3 << 1 << 2 << 0);
}
void tst_QListWidget::sortItems()
{
QFETCH(int, order);
- QFETCH(QStringList, initialList);
- QFETCH(QStringList, expectedList);
+ QFETCH(QVariantList, initialList);
+ QFETCH(QVariantList, expectedList);
QFETCH(IntList, expectedRows);
- testWidget->addItems(initialList);
+ foreach (const QVariant &data, initialList) {
+ QListWidgetItem *item = new QListWidgetItem(testWidget);
+ item->setData(Qt::DisplayRole, data);
+ }
QAbstractItemModel *model = testWidget->model();
QList<QPersistentModelIndex> persistent;
@@ -918,7 +933,7 @@ void tst_QListWidget::sortItems()
QCOMPARE(testWidget->count(), expectedList.count());
for (int i = 0; i < testWidget->count(); ++i)
- QCOMPARE(testWidget->item(i)->text(), expectedList.at(i));
+ QCOMPARE(testWidget->item(i)->text(), expectedList.at(i).toString());
for (int k = 0; k < testWidget->count(); ++k)
QCOMPARE(persistent.at(k).row(), expectedRows.at(k));