summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/serialization/qdatastream
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2024-02-23 19:41:30 +0100
committerThiago Macieira <thiago.macieira@intel.com>2024-03-26 15:20:31 -0700
commit1ebee8980ba31514079a01989168914bfd1e9f4f (patch)
treebb787b5be8799e9e895f6122bdcb92d127f50c4e /tests/auto/corelib/serialization/qdatastream
parente7667357712fe35b66a140916c18d8616b2e4f9c (diff)
QPolygonF: delegate QDataStream marshalling to QList
Like the QPolygon code. This fixes a mistake in failing to clear the list before de-marshalling in operator>>. Updated most of the QDataStream tests to have data in the objects they're streaming into, to ensure that the stream overwrites everything. Fixes: QTBUG-122684 Task-number: QTBUG-122704 Pick-to: 5.15 6.5 6.6 6.7 Change-Id: I01ec3c774d9943adb903fffd17b6920c72f5042b Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'tests/auto/corelib/serialization/qdatastream')
-rw-r--r--tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp35
1 files changed, 23 insertions, 12 deletions
diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
index 83d16e8265..b46dbf4b23 100644
--- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
@@ -2860,7 +2860,7 @@ QT_WARNING_POP
#endif // QT_DEPRECATED_SINCE(6, 11)
{
QDataStream stream(&data, QIODevice::ReadOnly);
- QByteArray buf;
+ QByteArray buf = "Content to be overwritten";
stream >> buf;
if (data.startsWith("\xff\xff\xff\xff")) {
@@ -2952,7 +2952,7 @@ void tst_QDataStream::status_QString()
QFETCH(QString, expectedString);
QDataStream stream(&data, QIODevice::ReadOnly);
- QString str;
+ QString str = "Content to be overwritten";
stream >> str;
QCOMPARE(str.size(), expectedString.size());
@@ -3047,7 +3047,7 @@ void tst_QDataStream::status_QBitArray()
QDataStream stream(&data, QIODevice::ReadOnly);
stream.setVersion(version);
- QBitArray str;
+ QBitArray str(255, true);
stream >> str;
if (sizeof(qsizetype) == sizeof(int))
@@ -3114,7 +3114,9 @@ void tst_QDataStream::status_QHash_QMap()
hash2.insert("L", "MN");
// ok
+ hash = hash2;
MAP_TEST(QByteArray("\x00\x00\x00\x00", 4), QDataStream::Ok, QDataStream::Ok, StringHash());
+ hash = hash2;
MAP_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00", 12), QDataStream::Ok, QDataStream::Ok, hash1);
MAP_TEST(QByteArray("\x00\x00\x00\x02\x00\x00\x00\x02\x00J\x00\x00\x00\x02\x00K"
"\x00\x00\x00\x02\x00L\x00\x00\x00\x04\x00M\x00N", 30), QDataStream::Ok, QDataStream::Ok, hash2);
@@ -3195,7 +3197,9 @@ void tst_QDataStream::status_QList_QVector()
someList.append("J");
someList.append("MN");
+ list = someList;
LIST_TEST(QByteArray("\x00\x00\x00\x00", 4), QDataStream::Ok, QDataStream::Ok, List());
+ list = someList;
LIST_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x00", 8), QDataStream::Ok, QDataStream::Ok, listWithEmptyString);
LIST_TEST(QByteArray("\x00\x00\x00\x02\x00\x00\x00\x02\x00J"
"\x00\x00\x00\x04\x00M\x00N", 18), QDataStream::Ok, QDataStream::Ok, someList);
@@ -3263,6 +3267,13 @@ void tst_QDataStream::streamRealDataTypes()
path.arcTo(4, 5, 6, 7, 8, 9);
path.quadTo(1, 2, 3, 4);
+ QPainterPath otherPath;
+ otherPath.arcTo(10, 4, 5, 6, 7, 8);
+ otherPath.lineTo(9, 0);
+ otherPath.cubicTo(0, 0, 10, 10, 20, 20);
+ otherPath.quadTo(2, 4, 5, 6);
+ QCOMPARE(otherPath.elementCount(), 12);
+
QColor color(64, 64, 64);
color.setAlphaF(0.5);
QRadialGradient radialGradient(5, 6, 7, 8, 9);
@@ -3294,17 +3305,17 @@ void tst_QDataStream::streamRealDataTypes()
file.close();
}
- QPointF point;
- QRectF rect;
- QPolygonF polygon;
+ QPointF point(1, 2);
+ QRectF rect(1, 2, 5, 6);
+ QPolygonF polygon {{3, 4}, {5, 6}};
QTransform transform;
- QPainterPath p;
+ QPainterPath p = otherPath;
QPicture pict;
- QTextLength textLength;
- QColor col;
- QBrush rGrad;
- QBrush cGrad;
- QPen pen;
+ QTextLength textLength(QTextLength::FixedLength, 2.5);
+ QColor col(128, 128, 127);
+ QBrush rGrad(Qt::CrossPattern);
+ QBrush cGrad(Qt::CrossPattern);
+ QPen pen(conicalBrush, 10);
QVERIFY(file.open(QIODevice::ReadOnly));
QDataStream stream(&file);