diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-12-29 23:11:04 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-01-07 01:05:07 +0100 |
commit | 252ddaa9075462000bb8e63288b9c15daeecca8a (patch) | |
tree | ebf8aface6306391a8080c22b4b132cc6f253ff0 /vcl/qa | |
parent | 0e37ded8d4aea25e5d9f7325fba0597f509147bc (diff) |
improve JpegWriterTest - detect type is correct during roundtrip
Change-Id: I4560be2dd1627caf8126142930c3479668689273
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108823
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/qa')
-rw-r--r-- | vcl/qa/cppunit/graphicfilter/filters-test.cxx | 2 | ||||
-rw-r--r-- | vcl/qa/cppunit/jpeg/JpegWriterTest.cxx | 16 |
2 files changed, 14 insertions, 4 deletions
diff --git a/vcl/qa/cppunit/graphicfilter/filters-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-test.cxx index 5a4443f1075a..aee1dda1407e 100644 --- a/vcl/qa/cppunit/graphicfilter/filters-test.cxx +++ b/vcl/qa/cppunit/graphicfilter/filters-test.cxx @@ -144,6 +144,8 @@ void VclFiltersTest::testExportImport() checkExportImport(u"png"); fprintf(stderr, "Check ExportImport BMP\n"); checkExportImport(u"bmp"); + fprintf(stderr, "Check ExportImport TIF\n"); + checkExportImport(u"tif"); } void VclFiltersTest::testCVEs() diff --git a/vcl/qa/cppunit/jpeg/JpegWriterTest.cxx b/vcl/qa/cppunit/jpeg/JpegWriterTest.cxx index b2144fe3b47e..f999c018df7c 100644 --- a/vcl/qa/cppunit/jpeg/JpegWriterTest.cxx +++ b/vcl/qa/cppunit/jpeg/JpegWriterTest.cxx @@ -16,6 +16,7 @@ #include <vcl/graphicfilter.hxx> #include <vcl/BitmapReadAccess.hxx> #include <tools/stream.hxx> +#include <graphic/GraphicFormatDetector.hxx> constexpr OUStringLiteral gaDataUrl(u"/vcl/qa/cppunit/jpeg/data/"); @@ -54,16 +55,23 @@ BitmapEx JpegWriterTest::roundtripJPG(const OUString& aURL) { return roundtripJP BitmapEx JpegWriterTest::roundtripJPG(const BitmapEx& bitmap) { - SvMemoryStream stream; + // EXPORT JPEG + SvMemoryStream aStream; GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); sal_uInt16 exportFormatJPG = rFilter.GetExportFormatNumberForShortName(JPG_SHORTNAME); Graphic aExportGraphic(bitmap); - ErrCode bResult = rFilter.ExportGraphic(aExportGraphic, "memory", stream, exportFormatJPG); + ErrCode bResult = rFilter.ExportGraphic(aExportGraphic, "memory", aStream, exportFormatJPG); CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, bResult); - stream.Seek(0); + //Detect the magic bytes - we need to be sure the file is actually a JPEG + aStream.Seek(0); + vcl::GraphicFormatDetector aDetector(aStream, ""); + CPPUNIT_ASSERT(aDetector.detect()); + CPPUNIT_ASSERT(aDetector.checkJPG()); + // IMPORT JPEG + aStream.Seek(0); Graphic aImportGraphic; sal_uInt16 importFormatJPG = rFilter.GetImportFormatNumberForShortName(JPG_SHORTNAME); - bResult = rFilter.ImportGraphic(aImportGraphic, "memory", stream, importFormatJPG); + bResult = rFilter.ImportGraphic(aImportGraphic, "memory", aStream, importFormatJPG); CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, bResult); return aImportGraphic.GetBitmapEx(); } |