diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qfileinfo/tst_qfileinfo.cpp | 42 | ||||
-rw-r--r-- | tests/auto/qfontmetrics/tst_qfontmetrics.cpp | 30 | ||||
-rw-r--r-- | tests/auto/qpixmapcache/tst_qpixmapcache.cpp | 17 |
3 files changed, 80 insertions, 9 deletions
diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index a87e306..306ca49 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -147,6 +147,9 @@ private slots: void isBundle_data(); void isBundle(); + void isLocalFs_data(); + void isLocalFs(); + void refresh(); #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) @@ -974,6 +977,22 @@ void tst_QFileInfo::isHidden_data() foreach (const QFileInfo& info, QDir::drives()) { QTest::newRow(qPrintable("drive." + info.path())) << info.path() << false; } + +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) + QTest::newRow("C:/RECYCLER") << QString::fromLatin1("C:/RECYCLER") << true; + QTest::newRow("C:/RECYCLER/.") << QString::fromLatin1("C:/RECYCLER/.") << false; + QTest::newRow("C:/RECYCLER/..") << QString::fromLatin1("C:/RECYCLER/..") << false; +#endif +#if defined(Q_OS_UNIX) + QTest::newRow("~/.qt") << QDir::homePath() + QString("/.qt") << true; + QTest::newRow("~/.qt/.") << QDir::homePath() + QString("/.qt/.") << false; + QTest::newRow("~/.qt/..") << QDir::homePath() + QString("/.qt/..") << false; +#endif + +#if !defined(Q_OS_WIN) + QTest::newRow("/bin/") << QString::fromLatin1("/bin/") << false; +#endif + #ifdef Q_OS_MAC QTest::newRow("mac_etc") << QString::fromLatin1("/etc") << true; QTest::newRow("mac_private_etc") << QString::fromLatin1("/private/etc") << false; @@ -1008,6 +1027,29 @@ void tst_QFileInfo::isBundle() QCOMPARE(fi.isBundle(), isBundle); } +void tst_QFileInfo::isLocalFs_data() +{ + QTest::addColumn<QString>("path"); + QTest::addColumn<bool>("isLocalFs"); + + QTest::newRow("local root") << QString::fromLatin1("/") << true; + QTest::newRow("local non-existent file") << QString::fromLatin1("/abrakadabra.boo") << true; + + QTest::newRow("qresource root") << QString::fromLatin1(":/") << false; +} + +void tst_QFileInfo::isLocalFs() +{ + QFETCH(QString, path); + QFETCH(bool, isLocalFs); + + QFileInfo info(path); + QFileInfoPrivate *privateInfo = getPrivate(info); + QVERIFY(privateInfo->data->fileEngine); + QCOMPARE(bool(privateInfo->data->fileEngine->fileFlags(QAbstractFileEngine::LocalDiskFlag) + & QAbstractFileEngine::LocalDiskFlag), isLocalFs); +} + void tst_QFileInfo::refresh() { #if defined(Q_OS_WINCE) diff --git a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp index 5658055..cae1126 100644 --- a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp @@ -71,6 +71,7 @@ private slots: void elidedText(); void veryNarrowElidedText(); void averageCharWidth(); + void elidedMultiLenght(); }; tst_QFontMetrics::tst_QFontMetrics() @@ -168,7 +169,8 @@ void tst_QFontMetrics::elidedText_data() QTest::addColumn<QFont>("font"); QTest::addColumn<QString>("text"); - QTest::newRow("helvetica hello") << QFont("helvetica",10) << QString("hello"); + QTest::newRow("helvetica hello") << QFont("helvetica",10) << QString("hello") ; + QTest::newRow("helvetica hello &Bye") << QFont("helvetica",10) << QString("hello&Bye") ; } @@ -178,9 +180,9 @@ void tst_QFontMetrics::elidedText() QFETCH(QString, text); QFontMetrics fm(font); int w = fm.width(text); - QString newtext = fm.elidedText(text,Qt::ElideRight,w); + QString newtext = fm.elidedText(text,Qt::ElideRight,w, 0); QCOMPARE(text,newtext); // should not elide - newtext = fm.elidedText(text,Qt::ElideRight,w-1); + newtext = fm.elidedText(text,Qt::ElideRight,w-1, 0); QVERIFY(text != newtext); // should elide } @@ -201,5 +203,27 @@ void tst_QFontMetrics::averageCharWidth() QVERIFY(fmf.averageCharWidth() != 0); } +void tst_QFontMetrics::elidedMultiLenght() +{ + QString text1 = "Long Text 1\x9cShorter\x9csmall"; + QString text1_long = "Long Text 1"; + QString text1_short = "Shorter"; + QString text1_small = "small"; + QFontMetrics fm = QFontMetrics(QFont()); + int width_long = fm.width(text1_long); + QCOMPARE(fm.elidedText(text1,Qt::ElideRight, 8000), text1_long); + QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_long), text1_long); + QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_long - 1), text1_short); + int width_short = fm.width(text1_short); + QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_short), text1_short); + QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_short - 1), text1_small); + + QChar ellipsisChar(0x2026); + QString text1_el = QString::fromLatin1("sm") + ellipsisChar; + int width_small = fm.width(text1_el); + QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_small + 1), text1_el); + +} + QTEST_MAIN(tst_QFontMetrics) #include "tst_qfontmetrics.moc" diff --git a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp index e71bd5d..7866df8 100644 --- a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp +++ b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp @@ -392,14 +392,19 @@ void tst_QPixmapCache::clear() QPixmap p1(10, 10); p1.fill(Qt::red); - for (int i = 0; i < 20000; ++i) +#ifdef Q_OS_WINCE + const int numberOfKeys = 10000; +#else + const int numberOfKeys = 20000; +#endif + for (int i = 0; i < numberOfKeys; ++i) QVERIFY(QPixmapCache::find("x" + QString::number(i)) == 0); - for (int j = 0; j < 20000; ++j) + for (int j = 0; j < numberOfKeys; ++j) QPixmapCache::insert(QString::number(j), p1); int num = 0; - for (int k = 0; k < 20000; ++k) { + for (int k = 0; k < numberOfKeys; ++k) { if (QPixmapCache::find(QString::number(k), p1)) ++num; } @@ -407,7 +412,7 @@ void tst_QPixmapCache::clear() QPixmapCache::clear(); - for (int k = 0; k < 20000; ++k) + for (int k = 0; k < numberOfKeys; ++k) QVERIFY(QPixmapCache::find(QString::number(k)) == 0); //The int part of the API @@ -415,12 +420,12 @@ void tst_QPixmapCache::clear() p2.fill(Qt::red); QList<QPixmapCache::Key> keys; - for (int k = 0; k < 20000; ++k) + for (int k = 0; k < numberOfKeys; ++k) keys.append(QPixmapCache::insert(p2)); QPixmapCache::clear(); - for (int k = 0; k < 20000; ++k) { + for (int k = 0; k < numberOfKeys; ++k) { QVERIFY(QPixmapCache::find(keys.at(k), &p1) == 0); QCOMPARE(getPrivate(keys[k])->isValid, false); } |