diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-04-30 10:48:44 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-05-03 08:22:45 +0200 |
commit | c79dd92480cbc409a7061da7f3dd3abaaf9a4883 (patch) | |
tree | 9f37223b82cf5404da66bfc87568db2954825f74 /vcl/qa/cppunit/TypeSerializerTest.cxx | |
parent | 18c97df0dcb348134d3ceac022a799338e02d7f5 (diff) |
vcl: add Graphic serialization (writing) to TypeSerializer + tests
Change-Id: I3c4845550e776c4c2c891d94db71bacea27c9a37
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93328
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/qa/cppunit/TypeSerializerTest.cxx')
-rw-r--r-- | vcl/qa/cppunit/TypeSerializerTest.cxx | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/TypeSerializerTest.cxx b/vcl/qa/cppunit/TypeSerializerTest.cxx index e5d3a259f803..0c737a4c4f03 100644 --- a/vcl/qa/cppunit/TypeSerializerTest.cxx +++ b/vcl/qa/cppunit/TypeSerializerTest.cxx @@ -130,6 +130,43 @@ void TypeSerializerTest::testGraphic() CPPUNIT_ASSERT_EQUAL(std::string("c2bed2099ce617f1cc035701de5186f0d43e3064"), toHexString(aHash)); } + + // Test TypeSerializer - Native Format 5 + { + SvMemoryStream aMemoryStream; + aMemoryStream.SetVersion(SOFFICE_FILEFORMAT_50); + aMemoryStream.SetCompressMode(SvStreamCompressFlags::NATIVE); + { + TypeSerializer aSerializer(aMemoryStream); + aSerializer.writeGraphic(aGraphic); + } + aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN); + + CPPUNIT_ASSERT_EQUAL(sal_uInt64(290), aMemoryStream.remainingSize()); + std::vector<unsigned char> aHash = calculateHash(aMemoryStream); + CPPUNIT_ASSERT_EQUAL(std::string("ee55ab6faa73b61b68bc3d5628d95f0d3c528e2a"), + toHexString(aHash)); + + aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN); + sal_uInt32 nType; + aMemoryStream.ReadUInt32(nType); + CPPUNIT_ASSERT_EQUAL(COMPAT_FORMAT('N', 'A', 'T', '5'), nType); + } + + // Test TypeSerializer - Normal + { + SvMemoryStream aMemoryStream; + { + TypeSerializer aSerializer(aMemoryStream); + aSerializer.writeGraphic(aGraphic); + } + aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN); + + CPPUNIT_ASSERT_EQUAL(sal_uInt64(233), aMemoryStream.remainingSize()); + std::vector<unsigned char> aHash = calculateHash(aMemoryStream); + CPPUNIT_ASSERT_EQUAL(std::string("c2bed2099ce617f1cc035701de5186f0d43e3064"), + toHexString(aHash)); + } } void TypeSerializerTest::testGraphic_Bitmap_NoGfxLink() @@ -155,6 +192,26 @@ void TypeSerializerTest::testGraphic_Bitmap_NoGfxLink() aMemoryStream.ReadUInt16(nType); CPPUNIT_ASSERT_EQUAL(sal_uInt16(0x4D42), nType); // Magic written with WriteDIBBitmapEx } + + // Test TypeSerializer + { + SvMemoryStream aMemoryStream; + { + TypeSerializer aSerializer(aMemoryStream); + aSerializer.writeGraphic(aGraphic); + } + aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN); + + CPPUNIT_ASSERT_EQUAL(sal_uInt64(383), aMemoryStream.remainingSize()); + std::vector<unsigned char> aHash = calculateHash(aMemoryStream); + CPPUNIT_ASSERT_EQUAL(std::string("da831418499146d51bf245fadf60b9111faa76c2"), + toHexString(aHash)); + + aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN); + sal_uInt16 nType; + aMemoryStream.ReadUInt16(nType); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(0x4D42), nType); // Magic written with WriteDIBBitmapEx + } } } // namespace |