From 3319639a6fd74d171224cb14c6e5bba0627621ba Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Mon, 28 Nov 2011 15:00:26 +1000 Subject: Allow nested read only maps of QVideoFrame. It's useful when video frame is accessed from multiple places like display and encoding. Change-Id: I8af175c780783216d8b7717cdf0744ad9bc95348 Reviewed-by: Michael Goddard --- tests/auto/unit/qvideoframe/tst_qvideoframe.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp b/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp index 595fbcf71..8206315a8 100644 --- a/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp +++ b/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp @@ -647,8 +647,27 @@ void tst_QVideoFrame::map() QVERIFY(frame.map(mode)); - // Mapping twice should fail, but leave it mapped (and the mode is ignored) - QVERIFY(!frame.map(mode)); + // Mapping multiple times is allowed in ReadOnly mode + if (mode == QAbstractVideoBuffer::ReadOnly) { + const uchar *bits = frame.bits(); + + QVERIFY(frame.map(QAbstractVideoBuffer::ReadOnly)); + QVERIFY(frame.isMapped()); + QCOMPARE(frame.bits(), bits); + + frame.unmap(); + //frame should still be mapped after the first nested unmap + QVERIFY(frame.isMapped()); + QCOMPARE(frame.bits(), bits); + + //re-mapping in Write or ReadWrite modes should fail + QVERIFY(!frame.map(QAbstractVideoBuffer::WriteOnly)); + QVERIFY(!frame.map(QAbstractVideoBuffer::ReadWrite)); + } else { + // Mapping twice in ReadWrite or WriteOnly modes should fail, but leave it mapped (and the mode is ignored) + QVERIFY(!frame.map(mode)); + QVERIFY(!frame.map(QAbstractVideoBuffer::ReadOnly)); + } QVERIFY(frame.bits()); QCOMPARE(frame.mappedBytes(), mappedBytes); -- cgit v1.2.3