summaryrefslogtreecommitdiff
path: root/vcl/qa
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-03-08 02:14:11 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-03-08 05:20:17 +0000
commitd062f097cc48bd53247b7fb0c677d90fcc430ab7 (patch)
treef76495b2c5ea562e618984c6d7421940b06b7a45 /vcl/qa
parenta179f6c91692076e7e17babf4890638caa398384 (diff)
Simplify usage of BinaryDataContainer
It is always used to store data read from streams Change-Id: I613bc446eaadf98d2b1c012002d38f23d79a40ba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148450 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl/qa')
-rw-r--r--vcl/qa/cppunit/BinaryDataContainerTest.cxx33
-rw-r--r--vcl/qa/cppunit/svm/svmtest.cxx10
2 files changed, 15 insertions, 28 deletions
diff --git a/vcl/qa/cppunit/BinaryDataContainerTest.cxx b/vcl/qa/cppunit/BinaryDataContainerTest.cxx
index 09bb036d8602..2f72a9d18214 100644
--- a/vcl/qa/cppunit/BinaryDataContainerTest.cxx
+++ b/vcl/qa/cppunit/BinaryDataContainerTest.cxx
@@ -30,45 +30,34 @@ void BinaryDataContainerTest::testConstruct()
{
{
BinaryDataContainer aContainer;
- CPPUNIT_ASSERT_EQUAL(true, aContainer.isEmpty());
+ CPPUNIT_ASSERT(aContainer.isEmpty());
CPPUNIT_ASSERT_EQUAL(size_t(0), aContainer.getSize());
}
{
- std::vector<sal_uInt8> aTestByteArray = { 1, 2, 3, 4 };
- BinaryDataContainer aContainer(aTestByteArray.data(), aTestByteArray.size());
- CPPUNIT_ASSERT_EQUAL(false, aContainer.isEmpty());
+ // construct a data array
+ sal_uInt8 aTestByteArray[] = { 1, 2, 3, 4 };
+ SvMemoryStream stream(aTestByteArray, std::size(aTestByteArray), StreamMode::READ);
+
+ BinaryDataContainer aContainer(stream, std::size(aTestByteArray));
+
+ CPPUNIT_ASSERT(!aContainer.isEmpty());
CPPUNIT_ASSERT_EQUAL(size_t(4), aContainer.getSize());
// Test Copy
BinaryDataContainer aCopyOfContainer = aContainer;
- CPPUNIT_ASSERT_EQUAL(false, aCopyOfContainer.isEmpty());
+ CPPUNIT_ASSERT(!aCopyOfContainer.isEmpty());
CPPUNIT_ASSERT_EQUAL(size_t(4), aCopyOfContainer.getSize());
CPPUNIT_ASSERT_EQUAL(aCopyOfContainer.getData(), aContainer.getData());
// Test Move
BinaryDataContainer aMovedInContainer = std::move(aCopyOfContainer);
- CPPUNIT_ASSERT_EQUAL(false, aMovedInContainer.isEmpty());
+ CPPUNIT_ASSERT(!aMovedInContainer.isEmpty());
CPPUNIT_ASSERT_EQUAL(size_t(4), aMovedInContainer.getSize());
CPPUNIT_ASSERT_EQUAL(aMovedInContainer.getData(), aContainer.getData());
- CPPUNIT_ASSERT_EQUAL(true, aCopyOfContainer.isEmpty());
+ CPPUNIT_ASSERT(aCopyOfContainer.isEmpty());
CPPUNIT_ASSERT_EQUAL(size_t(0), aCopyOfContainer.getSize());
}
- {
- // construct a unique_ptr data array
- std::vector<sal_uInt8> aTestByteArray = { 1, 2, 3, 4 };
- auto aConstructionByteArray = std::make_unique<std::vector<sal_uInt8>>(aTestByteArray);
-
- // remember for later to compare
- const sal_uInt8* pInternal = aConstructionByteArray->data();
-
- BinaryDataContainer aContainer(std::move(aConstructionByteArray));
-
- // make sure the unique_ptr was moved into BinaryDataContainer
- CPPUNIT_ASSERT_EQUAL(false, bool(aConstructionByteArray));
- // make sure we didn't copy data into BinaryDataContainer (pointers match)
- CPPUNIT_ASSERT_EQUAL(pInternal, aContainer.getData());
- }
}
} // namespace
diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx
index e8925ffda064..c5ca008b0a9b 100644
--- a/vcl/qa/cppunit/svm/svmtest.cxx
+++ b/vcl/qa/cppunit/svm/svmtest.cxx
@@ -2190,11 +2190,9 @@ void SvmTest::testEPS()
ScopedVclPtrInstance<VirtualDevice> pVirtualDev;
setupBaseVirtualDevice(*pVirtualDev, aGDIMetaFile);
- sal_uInt32 nDataSize = 3;
- std::unique_ptr<sal_uInt8[]> pBuffer (new sal_uInt8[nDataSize]);
- pBuffer[0] = 'a';
- pBuffer[1] = 'b';
- pBuffer[2] = 'c';
+ sal_uInt8 aBuffer[] = { 'a','b','c' };
+ SvMemoryStream stream(aBuffer, std::size(aBuffer), StreamMode::READ);
+ BinaryDataContainer aContainer(stream, std::size(aBuffer));
MapMode aMapMode1(MapUnit::Map100thInch);
aMapMode1.SetOrigin(Point(0, 1));
@@ -2208,7 +2206,7 @@ void SvmTest::testEPS()
pVirtualDev1->DrawPixel(Point(1, 8));
pVirtualDev1->DrawPixel(Point(2, 7));
- GfxLink aGfxLink(std::move(pBuffer), nDataSize, GfxLinkType::EpsBuffer);
+ GfxLink aGfxLink(aContainer, GfxLinkType::EpsBuffer);
aGfxLink.SetPrefMapMode(aMapMode1);
aGfxLink.SetUserId(12345);
aGfxLink.SetPrefSize(Size(3, 6));