summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/cmake/test_opengl_lib/CMakeLists.txt14
-rw-r--r--tests/auto/corelib/codecs/utf8/tst_utf8.cpp15
-rw-r--r--tests/auto/corelib/codecs/utf8/utf8data.cpp30
-rw-r--r--tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp1
-rw-r--r--tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp32
-rw-r--r--tests/auto/corelib/thread/thread.pro2
-rw-r--r--tests/auto/gui/kernel/qtouchevent/qtouchevent.pro1
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp2
-rw-r--r--tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp10
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp9
10 files changed, 95 insertions, 21 deletions
diff --git a/tests/auto/cmake/test_opengl_lib/CMakeLists.txt b/tests/auto/cmake/test_opengl_lib/CMakeLists.txt
index d9adb5a980..d2304a4183 100644
--- a/tests/auto/cmake/test_opengl_lib/CMakeLists.txt
+++ b/tests/auto/cmake/test_opengl_lib/CMakeLists.txt
@@ -8,11 +8,25 @@ find_package(Qt5Gui REQUIRED)
include_directories(${Qt5Gui_INCLUDE_DIRS} ${Qt5Gui_OPENGL_INCLUDE_DIRS} )
add_definitions(${Qt5Gui_DEFINITIONS})
+get_property(QtGui_enabled_features TARGET Qt5::Gui PROPERTY INTERFACE_QT_ENABLED_FEATURES)
+list(LENGTH QtGui_enabled_features _QtGui_enabled_featuresSize)
+if (_QtGui_enabled_featuresSize LESS 1)
+ message(SEND_ERROR "The INTERFACE_QT_ENABLED_FEATURES property of Qt5::Gui is empty!")
+endif()
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Gui_EXECUTABLE_COMPILE_FLAGS}")
if (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL GLESv2)
+ list(FIND QtGui_enabled_features "opengles2" _opengles2Index)
+ if(_opengles2Index EQUAL -1)
+ message(SEND_ERROR "The INTERFACE_QT_ENABLED_FEATURES property of Qt5::Gui does not contain the opengles2 feature!")
+ endif()
add_definitions(-DGL_IMPLEMENTATION_GLES2)
elseif (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL GL)
+ list(FIND QtGui_enabled_features "opengl" _openglIndex)
+ if(_openglIndex EQUAL -1)
+ message(SEND_ERROR "The INTERFACE_QT_ENABLED_FEATURES property of Qt5::Gui does not contain the opengl feature!")
+ endif()
add_definitions(-DGL_IMPLEMENTATION_GL)
else()
message(SEND_ERROR "Qt5Gui_OPENGL_IMPLEMENTATION does not contain valid data.")
diff --git a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp
index 8f78aa937c..9ce1748e72 100644
--- a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp
+++ b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
+** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2018 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -71,7 +71,7 @@ void tst_Utf8::initTestCase()
// is the locale UTF-8?
if (QString(QChar(QChar::ReplacementCharacter)).toLocal8Bit() == "\xEF\xBF\xBD") {
QTest::newRow("localecodec") << true;
- qDebug() << "locale is utf8";
+ qInfo() << "locale is utf8";
}
}
@@ -227,6 +227,15 @@ void tst_Utf8::invalidUtf8()
// GNU libc's iconv is known to accept U+FFFF and U+FFFE encoded as UTF-8
// OS X's iconv is known to accept those, plus surrogates and codepoints above U+10FFFF
if (!useLocale)
+ QVERIFY(decoder->hasFailure() || decoder->needsMoreData());
+ else if (!decoder->hasFailure() && !decoder->needsMoreData())
+ qWarning("System codec does not report failure when it should. Should report bug upstream.");
+
+ // add a continuation character and test that we don't accidentally use it
+ // (buffer overrun)
+ utf8 += char(0x80 | 0x3f);
+ decoder->toUnicode(utf8.constData(), utf8.size() - 1);
+ if (!useLocale)
QVERIFY(decoder->hasFailure());
else if (!decoder->hasFailure())
qWarning("System codec does not report failure when it should. Should report bug upstream.");
diff --git a/tests/auto/corelib/codecs/utf8/utf8data.cpp b/tests/auto/corelib/codecs/utf8/utf8data.cpp
index 2267dc8514..221e1d5579 100644
--- a/tests/auto/corelib/codecs/utf8/utf8data.cpp
+++ b/tests/auto/corelib/codecs/utf8/utf8data.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2018 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -29,15 +30,24 @@
void loadInvalidUtf8Rows()
{
- QTest::newRow("1char") << QByteArray("\x80");
- QTest::newRow("2chars-1") << QByteArray("\xC2\xC0");
- QTest::newRow("2chars-2") << QByteArray("\xC3\xDF");
- QTest::newRow("2chars-3") << QByteArray("\xC7\xF0");
- QTest::newRow("3chars-1") << QByteArray("\xE0\xA0\xC0");
- QTest::newRow("3chars-2") << QByteArray("\xE0\xC0\xA0");
- QTest::newRow("4chars-1") << QByteArray("\xF0\x90\x80\xC0");
- QTest::newRow("4chars-2") << QByteArray("\xF0\x90\xC0\x80");
- QTest::newRow("4chars-3") << QByteArray("\xF0\xC0\x80\x80");
+ // Wrong continuations
+ QTest::newRow("bad-continuation-1char") << QByteArray("\x80");
+ QTest::newRow("bad-continuation-2chars-1") << QByteArray("\xC2\xC0");
+ QTest::newRow("bad-continuation-2chars-2") << QByteArray("\xC3\xDF");
+ QTest::newRow("bad-continuation-2chars-3") << QByteArray("\xC7\xF0");
+ QTest::newRow("bad-continuation-3chars-1") << QByteArray("\xE0\xA0\xC0");
+ QTest::newRow("bad-continuation-3chars-2") << QByteArray("\xE0\xC0\xA0");
+ QTest::newRow("bad-continuation-4chars-1") << QByteArray("\xF0\x90\x80\xC0");
+ QTest::newRow("bad-continuation-4chars-2") << QByteArray("\xF0\x90\xC0\x80");
+ QTest::newRow("bad-continuation-4chars-3") << QByteArray("\xF0\xC0\x80\x80");
+
+ // Too short
+ QTest::newRow("too-short-2chars") << QByteArray("\xC2");
+ QTest::newRow("too-short-3chars-1") << QByteArray("\xE0");
+ QTest::newRow("too-short-3chars-2") << QByteArray("\xE0\xA0");
+ QTest::newRow("too-short-4chars-1") << QByteArray("\xF0");
+ QTest::newRow("too-short-4chars-2") << QByteArray("\xF0\x90");
+ QTest::newRow("too-short-4chars-3") << QByteArray("\xF0\x90\x80");
// Surrogate pairs must now be present either
// U+D800: 1101 10 0000 00 0000
diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
index 92d5cd8702..b69c993efb 100644
--- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
+++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp
@@ -1528,7 +1528,6 @@ void tst_QCborValue::toDiagnosticNotation_data()
QUuid uuid = QUuid::createUuid();
QMetaEnum me = QMetaEnum::fromType<QCborValue::Type>();
- auto st = [](QCborSimpleType t) { return QVariant::fromValue<SimpleTypeWrapper>(t); };
auto add = [me](const QCborValue &v, const QString &exp) {
auto addRow = [=](const char *prefix) -> QTestData & {
QCborValue::Type t = v.type();
diff --git a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
index 16a4200b5d..8fdf91b090 100644
--- a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
+++ b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
@@ -577,6 +577,8 @@ private slots:
void invalidStringCharacters() const;
void hasError() const;
void readBack() const;
+ void roundTrip() const;
+ void roundTrip_data() const;
private:
static QByteArray readFile(const QString &filename);
@@ -1741,5 +1743,35 @@ void tst_QXmlStream::readBack() const
}
}
+void tst_QXmlStream::roundTrip_data() const
+{
+ QTest::addColumn<QString>("in");
+
+ QTest::newRow("QTBUG-63434") <<
+ "<?xml version=\"1.0\"?>"
+ "<root>"
+ "<father>"
+ "<child xmlns:unknown=\"http://mydomain\">Text</child>"
+ "</father>"
+ "</root>\n";
+}
+
+void tst_QXmlStream::roundTrip() const
+{
+ QFETCH(QString, in);
+ QString out;
+
+ QXmlStreamReader reader(in);
+ QXmlStreamWriter writer(&out);
+
+ while (!reader.atEnd()) {
+ reader.readNext();
+ QVERIFY(!reader.hasError());
+ writer.writeCurrentToken(reader);
+ QVERIFY(!writer.hasError());
+ }
+ QCOMPARE(out, in);
+}
+
#include "tst_qxmlstream.moc"
// vim: et:ts=4:sw=4:sts=4
diff --git a/tests/auto/corelib/thread/thread.pro b/tests/auto/corelib/thread/thread.pro
index dc60e5a7f5..90b8d6806e 100644
--- a/tests/auto/corelib/thread/thread.pro
+++ b/tests/auto/corelib/thread/thread.pro
@@ -1,6 +1,6 @@
TEMPLATE=subdirs
-qtHaveFeature(thread) {
+qtConfig(thread) {
SUBDIRS=\
qatomicint \
qatomicinteger \
diff --git a/tests/auto/gui/kernel/qtouchevent/qtouchevent.pro b/tests/auto/gui/kernel/qtouchevent/qtouchevent.pro
index b1e3c10724..8506a005bc 100644
--- a/tests/auto/gui/kernel/qtouchevent/qtouchevent.pro
+++ b/tests/auto/gui/kernel/qtouchevent/qtouchevent.pro
@@ -1,5 +1,4 @@
CONFIG += testcase
-osx: CONFIG += insignificant_test # QTBUG-46266, crashes
SOURCES=tst_qtouchevent.cpp
TARGET=tst_qtouchevent
QT += testlib widgets gui-private
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 877306e8b8..9bf9e99bf9 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -5024,7 +5024,7 @@ void tst_QPainter::drawPolyline_data()
{
QTest::addColumn< QVector<QPointF> >("points");
- QTest::newRow("basic") << (QVector<QPointF>() << QPointF(10, 10) << QPointF(20, 10) << QPointF(20, 20) << QPointF(10, 20));
+ QTest::newRow("basic") << (QVector<QPointF>() << QPointF(10, 10) << QPointF(20, 10) << QPointF(20, 20));
QTest::newRow("clipped") << (QVector<QPointF>() << QPoint(-10, 100) << QPoint(-1, 100) << QPoint(-1, -2) << QPoint(100, -2) << QPoint(100, 40)); // QTBUG-31579
QTest::newRow("shortsegment") << (QVector<QPointF>() << QPoint(20, 100) << QPoint(20, 99) << QPoint(21, 99) << QPoint(21, 104)); // QTBUG-42398
QTest::newRow("edge") << (QVector<QPointF>() << QPointF(4.5, 121.6) << QPointF(9.4, 150.9) << QPointF(14.2, 184.8) << QPointF(19.1, 130.4));
diff --git a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp
index d2c4adb888..2bc611fe93 100644
--- a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp
+++ b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp
@@ -137,6 +137,7 @@ private slots:
void cursorPositionWithBlockUndoAndRedo3();
void joinNonEmptyRemovedBlockUserState();
+ void crashOnDetachingDanglingCursor();
private:
int blockCount();
@@ -1974,5 +1975,14 @@ void tst_QTextCursor::joinNonEmptyRemovedBlockUserState()
QCOMPARE(cursor.block().userState(), 10);
}
+void tst_QTextCursor::crashOnDetachingDanglingCursor()
+{
+ QTextDocument *document = new QTextDocument;
+ QTextCursor cursor(document);
+ QTextCursor cursor2 = cursor;
+ delete document;
+ cursor2.setPosition(0); // Don't crash here
+}
+
QTEST_MAIN(tst_QTextCursor)
#include "tst_qtextcursor.moc"
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index 1130a47260..27eac03880 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -2206,10 +2206,11 @@ void tst_QGraphicsItem::setMatrix()
QCOMPARE(spy.count(), 3);
QList<QRectF> rlist = qvariant_cast<QList<QRectF> >(spy.last().at(0));
- QCOMPARE(rlist.size(), 3);
- QCOMPARE(rlist.at(0), rotatedRect); // From item.setMatrix() (clearing rotated rect)
- QCOMPARE(rlist.at(1), rotatedRect); // From scene.update() (updating scene rect)
- QCOMPARE(rlist.at(2), unrotatedRect); // From post-update (update current state)
+ QCOMPARE(rlist.size(), 2);
+ // From item.setMatrix() (clearing rotated rect), from scene.update() (updating scene rect),
+ // squashed into one
+ QCOMPARE(rlist.at(0), rotatedRect);
+ QCOMPARE(rlist.at(1), unrotatedRect); // From post-update (update current state)
}
static QList<QGraphicsItem *> _paintedItems;