summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/compilerwarnings/test_cpp.txt3
-rw-r--r--tests/auto/compilerwarnings/tst_compilerwarnings.cpp7
-rw-r--r--tests/auto/qdom/tst_qdom.cpp1
-rw-r--r--tests/auto/qmetaobject/tst_qmetaobject.cpp6
-rw-r--r--tests/auto/qregexp/tst_qregexp.cpp18
-rw-r--r--tests/auto/qstatictext/tst_qstatictext.cpp106
-rw-r--r--tests/auto/qstring/tst_qstring.cpp12
-rw-r--r--tests/auto/qtextlayout/tst_qtextlayout.cpp30
8 files changed, 179 insertions, 4 deletions
diff --git a/tests/auto/compilerwarnings/test_cpp.txt b/tests/auto/compilerwarnings/test_cpp.txt
index 62b35eb..1d317b8 100644
--- a/tests/auto/compilerwarnings/test_cpp.txt
+++ b/tests/auto/compilerwarnings/test_cpp.txt
@@ -58,6 +58,9 @@
#include <QtDBus/QtDBus>
#endif
+#include <QtDeclarative/QtDeclarative>
+
+
#ifndef Q_OS_MAC
int main(int, char **)
{
diff --git a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp
index 82c327a..8d344d8 100644
--- a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp
+++ b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp
@@ -114,6 +114,9 @@ void tst_CompilerWarnings::warnings_data()
QTest::addColumn<QStringList>("cflags");
QTest::newRow("standard") << QStringList();
+ QTest::newRow("warn deprecated, fast plus, no debug") << (QStringList() << "-DQT_DEPRECATED_WARNINGS"
+ << "-DQT_USE_FAST_OPERATOR_PLUS" << "-DQT_NU_DEBUG" << "-DQT_NO_DEBUG_STREAM" << "-DQT_NO_WARNING_OUTPUT");
+ QTest::newRow("no deprecated, no keywords") << (QStringList() << "-DQT_NO_DEPRECATED" << "-DQT_NO_KEYWORDS");
#if 0
#ifdef Q_WS_QWS
@@ -136,14 +139,14 @@ void tst_CompilerWarnings::warnings()
QSKIP("gcc 3.x outputs too many bogus warnings", SkipAll);
#endif
- static QString tmpFile;
+ /*static*/ QString tmpFile;
if (tmpFile.isEmpty()) {
QTemporaryFile tmpQFile;
tmpQFile.open();
tmpFile = tmpQFile.fileName();
tmpQFile.close();
}
- static QString tmpSourceFile;
+ /*static*/ QString tmpSourceFile;
bool openResult = true;
const QString tmpBaseName("XXXXXX-test.cpp");
QString templatePath = QDir::temp().absoluteFilePath(tmpBaseName);
diff --git a/tests/auto/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp
index 0f6cdaa..8bf7620 100644
--- a/tests/auto/qdom/tst_qdom.cpp
+++ b/tests/auto/qdom/tst_qdom.cpp
@@ -1776,6 +1776,7 @@ void tst_QDom::crashInSetContent() const
QDomImplementation::setInvalidDataPolicy(QDomImplementation::ReturnNullNode);
QDomDocument docImport;
+ QCOMPARE(docImport.setContent(QLatin1String("<a:>text</a:>"), true), false);
QVERIFY(docImport.setContent(QLatin1String("<?xml version=\"1.0\"?><e/>")));
}
diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp
index 62416b1..bb96da1 100644
--- a/tests/auto/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp
@@ -714,6 +714,8 @@ void tst_QMetaObject::normalizedSignature_data()
QTest::newRow("const12") << "void foo(Foo<Bar>const*const *const)" << "void foo(Foo<Bar>*const*const)";
QTest::newRow("const13") << "void foo(const Foo<Bar>&)" << "void foo(Foo<Bar>)";
QTest::newRow("const14") << "void foo(Foo<Bar>const&)" << "void foo(Foo<Bar>)";
+
+ QTest::newRow("invalid1") << "a( b" << "a(b";
}
void tst_QMetaObject::normalizedSignature()
@@ -721,7 +723,7 @@ void tst_QMetaObject::normalizedSignature()
QFETCH(QString, signature);
QFETCH(QString, result);
- QCOMPARE(QString::fromLatin1(QMetaObject::normalizedSignature(signature.toLatin1())), result);
+ QCOMPARE(QMetaObject::normalizedSignature(signature.toLatin1()), result.toLatin1());
}
void tst_QMetaObject::normalizedType_data()
@@ -759,7 +761,7 @@ void tst_QMetaObject::normalizedType()
QFETCH(QString, type);
QFETCH(QString, result);
- QCOMPARE(QString::fromLatin1(QMetaObject::normalizedType(type.toLatin1())), result);
+ QCOMPARE(QMetaObject::normalizedType(type.toLatin1()), result.toLatin1());
}
void tst_QMetaObject::customPropertyType()
diff --git a/tests/auto/qregexp/tst_qregexp.cpp b/tests/auto/qregexp/tst_qregexp.cpp
index ea07323..d0d26ee 100644
--- a/tests/auto/qregexp/tst_qregexp.cpp
+++ b/tests/auto/qregexp/tst_qregexp.cpp
@@ -105,6 +105,7 @@ private slots:
void QTBUG_7049_data();
void QTBUG_7049();
+ void interval();
};
// Testing get/set functions
@@ -1426,5 +1427,22 @@ void tst_QRegExp::QTBUG_7049()
QCOMPARE( re.cap(2), cap2 );
}
+void tst_QRegExp::interval()
+{
+ {
+ QRegExp exp("a{0,1}");
+ QVERIFY(exp.isValid());
+ }
+ {
+ QRegExp exp("a{1,1}");
+ QVERIFY(exp.isValid());
+ }
+ {
+ QRegExp exp("a{1,0}");
+ QVERIFY(!exp.isValid());
+ }
+}
+
+
QTEST_APPLESS_MAIN(tst_QRegExp)
#include "tst_qregexp.moc"
diff --git a/tests/auto/qstatictext/tst_qstatictext.cpp b/tests/auto/qstatictext/tst_qstatictext.cpp
index 1d166f4..0ae5320 100644
--- a/tests/auto/qstatictext/tst_qstatictext.cpp
+++ b/tests/auto/qstatictext/tst_qstatictext.cpp
@@ -85,6 +85,10 @@ private slots:
void setPenPlainText();
void setPenRichText();
void richTextOverridesPen();
+
+ void drawStruckOutText();
+ void drawOverlinedText();
+ void drawUnderlinedText();
};
void tst_QStaticText::init()
@@ -620,5 +624,107 @@ void tst_QStaticText::richTextOverridesPen()
}
}
+void tst_QStaticText::drawStruckOutText()
+{
+ QPixmap imageDrawText(1000, 1000);
+ QPixmap imageDrawStaticText(1000, 1000);
+
+ imageDrawText.fill(Qt::white);
+ imageDrawStaticText.fill(Qt::white);
+
+ QString s = QString::fromLatin1("Foobar");
+
+ QFont font;
+ font.setStrikeOut(true);
+
+ {
+ QPainter p(&imageDrawText);
+ p.setFont(font);
+ p.drawText(QPointF(50, 50), s);
+ }
+
+ {
+ QPainter p(&imageDrawStaticText);
+ QStaticText text = QStaticText(s);
+ p.setFont(font);
+ p.drawStaticText(QPointF(50, 50 - QFontMetricsF(p.font()).ascent()), text);
+ }
+
+#if defined(DEBUG_SAVE_IMAGE)
+ imageDrawText.save("drawStruckOutText_imageDrawText.png");
+ imageDrawStaticText.save("drawStruckOutText_imageDrawStaticText.png");
+#endif
+
+ QCOMPARE(imageDrawText, imageDrawStaticText);
+}
+
+void tst_QStaticText::drawOverlinedText()
+{
+ QPixmap imageDrawText(1000, 1000);
+ QPixmap imageDrawStaticText(1000, 1000);
+
+ imageDrawText.fill(Qt::white);
+ imageDrawStaticText.fill(Qt::white);
+
+ QString s = QString::fromLatin1("Foobar");
+
+ QFont font;
+ font.setOverline(true);
+
+ {
+ QPainter p(&imageDrawText);
+ p.setFont(font);
+ p.drawText(QPointF(50, 50), s);
+ }
+
+ {
+ QPainter p(&imageDrawStaticText);
+ QStaticText text = QStaticText(s);
+ p.setFont(font);
+ p.drawStaticText(QPointF(50, 50 - QFontMetricsF(p.font()).ascent()), text);
+ }
+
+#if defined(DEBUG_SAVE_IMAGE)
+ imageDrawText.save("drawOverlinedText_imageDrawText.png");
+ imageDrawStaticText.save("drawOverlinedText_imageDrawStaticText.png");
+#endif
+
+ QCOMPARE(imageDrawText, imageDrawStaticText);
+}
+
+void tst_QStaticText::drawUnderlinedText()
+{
+ QPixmap imageDrawText(1000, 1000);
+ QPixmap imageDrawStaticText(1000, 1000);
+
+ imageDrawText.fill(Qt::white);
+ imageDrawStaticText.fill(Qt::white);
+
+ QString s = QString::fromLatin1("Foobar");
+
+ QFont font;
+ font.setUnderline(true);
+
+ {
+ QPainter p(&imageDrawText);
+ p.setFont(font);
+ p.drawText(QPointF(50, 50), s);
+ }
+
+ {
+ QPainter p(&imageDrawStaticText);
+ QStaticText text = QStaticText(s);
+ p.setFont(font);
+ p.drawStaticText(QPointF(50, 50 - QFontMetricsF(p.font()).ascent()), text);
+ }
+
+#if defined(DEBUG_SAVE_IMAGE)
+ imageDrawText.save("drawUnderlinedText_imageDrawText.png");
+ imageDrawStaticText.save("drawUnderlinedText_imageDrawStaticText.png");
+#endif
+
+ QCOMPARE(imageDrawText, imageDrawStaticText);
+}
+
QTEST_MAIN(tst_QStaticText)
#include "tst_qstatictext.moc"
diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp
index c887936..ef82769 100644
--- a/tests/auto/qstring/tst_qstring.cpp
+++ b/tests/auto/qstring/tst_qstring.cpp
@@ -208,6 +208,7 @@ private slots:
void repeated_data() const;
void task262677remove();
void QTBUG10404_compareRef();
+ void QTBUG9281_arg_locale();
};
typedef QList<int> IntList;
@@ -4860,6 +4861,17 @@ void tst_QString::QTBUG10404_compareRef()
QVERIFY(QStringRef(&a2, 1, 2).compare(QStringRef(&a, 1, 3), Qt::CaseInsensitive) < 0);
}
+void tst_QString::QTBUG9281_arg_locale()
+{
+ QLocale l(QLocale::English, QLocale::UnitedKingdom);
+ l.setNumberOptions(QLocale::OmitGroupSeparator);
+ QLocale::setDefault(l);
+ QString str("*%L1*%L2*");
+ str = str.arg(123456).arg(1234.56);
+ QCOMPARE(str, QString::fromLatin1("*123456*1234.56*"));
+ QLocale::setDefault(QLocale::C);
+}
+
QTEST_APPLESS_MAIN(tst_QString)
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp
index f798faf..659ba1a 100644
--- a/tests/auto/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp
@@ -122,6 +122,7 @@ private slots:
void smallTextLengthWrapAtWordBoundaryOrAnywhere();
void testLineBreakingAllSpaces();
void lineWidthFromBOM();
+ void textWidthVsWIdth();
private:
@@ -1359,5 +1360,34 @@ void tst_QTextLayout::glyphLessItems()
}
}
+void tst_QTextLayout::textWidthVsWIdth()
+{
+ QTextLayout layout;
+ QTextOption opt;
+ opt.setWrapMode(QTextOption::WrapAnywhere);
+ layout.setTextOption(opt);
+ layout.setText(QString::fromLatin1(
+ "g++ -c -m64 -pipe -g -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -D_REENTRANT -fPIC -DCORE_LIBRARY -DIDE_LIBRARY_BASENAME=\"lib\" -DWITH_TESTS "
+ "-DQT_NO_CAST_TO_ASCII -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_FAST_CONCATENATION -DQT_PLUGIN -DQT_TESTLIB_LIB -DQT_SCRIPT_LIB -DQT_SVG_LIB -DQT_SQL_LIB -DQT_XM"
+ "L_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../../qt-qml/mkspecs/linux-g++-64 -I. -I../../../../qt-qml/include/QtCore -I../../../."
+ "./qt-qml/include/QtNetwork -I../../../../qt-qml/include/QtGui -I../../../../qt-qml/include/QtXml -I../../../../qt-qml/include/QtSql -I../../../../qt-qml/inc"
+ "lude/QtSvg -I../../../../qt-qml/include/QtScript -I../../../../qt-qml/include/QtTest -I../../../../qt-qml/include -I../../../../qt-qml/include/QtHelp -I../."
+ "./libs -I/home/ettrich/dev/creator/tools -I../../plugins -I../../shared/scriptwrapper -I../../libs/3rdparty/botan/build -Idialogs -Iactionmanager -Ieditorma"
+ "nager -Iprogressmanager -Iscriptmanager -I.moc/debug-shared -I.uic -o .obj/debug-shared/sidebar.o sidebar.cpp"));
+
+ // textWidth includes right bearing, but it should never be LARGER than width if there is space for at least one character
+ for (int width = 100; width < 1000; ++width) {
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ line.setLineWidth(width);
+ layout.endLayout();
+
+ qreal textWidthIsLargerBy = qMax(qreal(0), line.naturalTextWidth() - line.width());
+ qreal thisMustBeZero = 0;
+ QCOMPARE(textWidthIsLargerBy, thisMustBeZero);
+ }
+}
+
+
QTEST_MAIN(tst_QTextLayout)
#include "tst_qtextlayout.moc"