summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp15
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp62
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp2
-rw-r--r--tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp1
-rw-r--r--tests/auto/tools/uic/baseline/imagedialog.ui.h4
-rw-r--r--tests/auto/tools/uic/baseline/newdynamicpropertydialog.ui.h2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp3
7 files changed, 79 insertions, 10 deletions
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 1f0ace0dd3..59f271d727 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -763,6 +763,7 @@ void tst_QProcess::restartProcess()
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::closeWriteChannel()
{
+ QByteArray testData("Data to read");
QProcess more;
more.start("testProcessEOF/testProcessEOF");
@@ -770,19 +771,21 @@ void tst_QProcess::closeWriteChannel()
QVERIFY(!more.waitForReadyRead(250));
QCOMPARE(more.error(), QProcess::Timedout);
- QVERIFY(more.write("Data to read") != -1);
+ QCOMPARE(more.write(testData), qint64(testData.size()));
QVERIFY(!more.waitForReadyRead(250));
QCOMPARE(more.error(), QProcess::Timedout);
more.closeWriteChannel();
-
- QVERIFY(more.waitForReadyRead(5000));
- QVERIFY(more.readAll().startsWith("Data to read"));
+ // During closeWriteChannel() call, we might also get an I/O completion
+ // on the read pipe. So, take this into account before waiting for
+ // the new incoming data.
+ while (more.bytesAvailable() < testData.size())
+ QVERIFY(more.waitForReadyRead(5000));
+ QCOMPARE(more.readAll(), testData);
if (more.state() == QProcess::Running)
- more.write("q");
- QVERIFY(more.waitForFinished(5000));
+ QVERIFY(more.waitForFinished(5000));
QCOMPARE(more.exitStatus(), QProcess::NormalExit);
QCOMPARE(more.exitCode(), 0);
}
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 6aeea70cbf..44b8135410 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -500,6 +500,8 @@ private slots:
void fromLocal8Bit();
void local8Bit_data();
void local8Bit();
+ void invalidToLocal8Bit_data();
+ void invalidToLocal8Bit();
void nullFromLocal8Bit();
void fromLatin1Roundtrip_data();
void fromLatin1Roundtrip();
@@ -4298,6 +4300,66 @@ void tst_QString::local8Bit()
QCOMPARE(local8Bit.toLocal8Bit(), QByteArray(result));
}
+void tst_QString::invalidToLocal8Bit_data()
+{
+ QTest::addColumn<QString>("unicode");
+ QTest::addColumn<QByteArray>("expect"); // Initial validly-converted prefix
+
+ {
+ const QChar malformed[] = { 'A', 0xd800, 'B', 0 };
+ const char expected[] = "A";
+ QTest::newRow("LoneHighSurrogate")
+ << QString(malformed, sizeof(malformed) / sizeof(QChar))
+ // Don't include the terminating '\0' of expected:
+ << QByteArray(expected, sizeof(expected) / sizeof(char) - 1);
+ }
+ {
+ const QChar malformed[] = { 'A', 0xdc00, 'B', 0 };
+ const char expected[] = "A";
+ QTest::newRow("LoneLowSurrogate")
+ << QString(malformed, sizeof(malformed) / sizeof(QChar))
+ << QByteArray(expected, sizeof(expected) / sizeof(char) - 1);
+ }
+ {
+ const QChar malformed[] = { 'A', 0xd800, 0xd801, 'B', 0 };
+ const char expected[] = "A";
+ QTest::newRow("DoubleHighSurrogate")
+ << QString(malformed, sizeof(malformed) / sizeof(QChar))
+ << QByteArray(expected, sizeof(expected) / sizeof(char) - 1);
+ }
+ {
+ const QChar malformed[] = { 'A', 0xdc00, 0xdc01, 'B', 0 };
+ const char expected[] = "A";
+ QTest::newRow("DoubleLowSurrogate")
+ << QString(malformed, sizeof(malformed) / sizeof(QChar))
+ << QByteArray(expected, sizeof(expected) / sizeof(char) - 1);
+ }
+ {
+ const QChar malformed[] = { 'A', 0xdc00, 0xd800, 'B', 0 };
+ const char expected[] = "A";
+ QTest::newRow("ReversedSurrogates") // low before high
+ << QString(malformed, sizeof(malformed) / sizeof(QChar))
+ << QByteArray(expected, sizeof(expected) / sizeof(char) - 1);
+ }
+}
+
+void tst_QString::invalidToLocal8Bit()
+{
+ QFETCH(QString, unicode);
+ QFETCH(QByteArray, expect);
+ QByteArray local = unicode.toLocal8Bit();
+ /*
+ The main concern of this test is to check that any error-reporting that
+ toLocal8Bit() prompts on failure isn't dependent on outputting the data
+ it's converting via toLocal8Bit(), which would be apt to recurse. So the
+ real purpose of this QVERIFY(), for all that we should indeed check we get
+ the borked output that matches what we can reliably expect (despite
+ variation in how codecs respond to errors), is to verify that we got here
+ - i.e. we didn't crash in such a recursive stack over-flow.
+ */
+ QVERIFY(local.startsWith(expect));
+}
+
void tst_QString::nullFromLocal8Bit()
{
QString a;
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index cffa444c97..00e7436c0f 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -279,6 +279,8 @@ void tst_QColor::name_data()
QTest::newRow("global color darkMagenta") << QColor(Qt::darkMagenta) << "#800080" << QColor::HexRgb;
QTest::newRow("global color darkYellow") << QColor(Qt::darkYellow) << "#808000" << QColor::HexRgb;
QTest::newRow("transparent red") << QColor(255, 0, 0, 102) << "#66ff0000" << QColor::HexArgb;
+ QTest::newRow("fully_transparent_green_rgb") << QColor(0, 0, 255, 0) << "#0000ff" << QColor::HexRgb;
+ QTest::newRow("fully_transparent_green_argb") << QColor(0, 0, 255, 0) << "#000000ff" << QColor::HexArgb;
}
void tst_QColor::name()
diff --git a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp
index 041a0ce16c..b3ecd884cd 100644
--- a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp
+++ b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp
@@ -111,6 +111,7 @@ void tst_PlatformSocketEngine::construction()
QCOMPARE(socketDevice.peerAddress(), QHostAddress());
QCOMPARE(socketDevice.peerPort(), quint16(0));
QCOMPARE(socketDevice.error(), QAbstractSocket::UnknownSocketError);
+ QCOMPARE(socketDevice.option(QNativeSocketEngine::NonBlockingSocketOption), -1);
QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::bytesAvailable() was called in QAbstractSocket::UnconnectedState");
QCOMPARE(socketDevice.bytesAvailable(), -1);
diff --git a/tests/auto/tools/uic/baseline/imagedialog.ui.h b/tests/auto/tools/uic/baseline/imagedialog.ui.h
index c02c40c2c1..99e853b7a8 100644
--- a/tests/auto/tools/uic/baseline/imagedialog.ui.h
+++ b/tests/auto/tools/uic/baseline/imagedialog.ui.h
@@ -155,7 +155,7 @@ public:
vboxLayout->addLayout(gridLayout);
- spacerItem = new QSpacerItem(QSizePolicy::Minimum, QSizePolicy::Expanding);
+ spacerItem = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
vboxLayout->addItem(spacerItem);
@@ -166,7 +166,7 @@ public:
hboxLayout->setContentsMargins(1, 1, 1, 1);
hboxLayout->setObjectName(QStringLiteral("hboxLayout"));
hboxLayout->setObjectName(QStringLiteral(""));
- spacerItem1 = new QSpacerItem(QSizePolicy::Expanding, QSizePolicy::Minimum);
+ spacerItem1 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout->addItem(spacerItem1);
diff --git a/tests/auto/tools/uic/baseline/newdynamicpropertydialog.ui.h b/tests/auto/tools/uic/baseline/newdynamicpropertydialog.ui.h
index ca7bd253a8..3c4e0ba09e 100644
--- a/tests/auto/tools/uic/baseline/newdynamicpropertydialog.ui.h
+++ b/tests/auto/tools/uic/baseline/newdynamicpropertydialog.ui.h
@@ -91,7 +91,7 @@ public:
verticalLayout->addLayout(formLayout);
- spacerItem = new QSpacerItem(QSizePolicy::Minimum, QSizePolicy::Expanding);
+ spacerItem = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
verticalLayout->addItem(spacerItem);
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index 8253a44b21..4e30b75dc5 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -397,6 +397,7 @@ void tst_QGraphicsProxyWidget::setWidget()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
+ QScopedPointer<QStyle> style(QStyleFactory::create(QLatin1String("Fusion")));
QVERIFY(QTest::qWaitForWindowExposed(&view));
QPointer<SubQGraphicsProxyWidget> proxy = new SubQGraphicsProxyWidget;
SubQGraphicsProxyWidget parentProxy;
@@ -419,7 +420,7 @@ void tst_QGraphicsProxyWidget::setWidget()
#endif
widget->setPalette(QPalette(Qt::magenta));
widget->setLayoutDirection(Qt::RightToLeft);
- widget->setStyle(QStyleFactory::create(QLatin1String("Fusion")));
+ widget->setStyle(style.data());
widget->setFont(QFont("Times"));
widget->setVisible(true);
QApplication::setActiveWindow(widget);