vcl/qa/cppunit/jpeg/JpegReaderTest.cxx     |   57 ++++++++++++++---------------
 vcl/qa/cppunit/jpeg/data/JPEGTestCMYK.jpeg |binary
 vcl/qa/cppunit/jpeg/data/JPEGTestGray.jpeg |binary
 vcl/qa/cppunit/jpeg/data/JPEGTestRGB.jpeg  |binary
 4 files changed, 29 insertions(+), 28 deletions(-)

New commits:
commit 7446faec4e319afaf2f0b043c45ed0df6d1885dd
Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
Date:   Tue Nov 8 19:15:23 2016 +0100

    vcl: non-symetric image to test JPEG import
    
    Previously we used a symetric image to test JPEG import. This has
    the flaw that we doesn't warn if the orientation of the JPEG
    image was not correct. This commit fixes this flaw by making all
    test images non-symetrical.
    
    Change-Id: If87d257ae44d85b6a9042d09d62ba785ffc5c426
    Reviewed-on: https://gerrit.libreoffice.org/30709
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/vcl/qa/cppunit/jpeg/JpegReaderTest.cxx 
b/vcl/qa/cppunit/jpeg/JpegReaderTest.cxx
index 99d78e3..8fcba6e 100644
--- a/vcl/qa/cppunit/jpeg/JpegReaderTest.cxx
+++ b/vcl/qa/cppunit/jpeg/JpegReaderTest.cxx
@@ -49,11 +49,12 @@ int deltaColor(BitmapColor aColor1, BitmapColor aColor2)
     return std::max(std::max(deltaR, deltaG), deltaB);
 }
 
-bool checkRect(Bitmap& rBitmap, int aLayerNumber, Color aExpectedColor, int 
nMaxDelta)
+bool checkRect(Bitmap& rBitmap, int aLayerNumber, long nAreaHeight, long 
nAreaWidth, Color aExpectedColor, int nMaxDelta)
 {
     Bitmap::ScopedWriteAccess pAccess(rBitmap);
-    long nHeight = pAccess->Height();
-    long nWidth = pAccess->Width();
+
+    long nWidth  = std::min(nAreaWidth,  pAccess->Width());
+    long nHeight = std::min(nAreaHeight, pAccess->Height());
 
     long firstX = 0 + aLayerNumber;
     long firstY = 0 + aLayerNumber;
@@ -65,24 +66,24 @@ bool checkRect(Bitmap& rBitmap, int aLayerNumber, Color 
aExpectedColor, int nMax
 
     for (long y = firstY; y <= lastY; y++)
     {
-        Color aColorFirst = pAccess->GetPixel(firstX, y);
+        Color aColorFirst = pAccess->GetPixel(y, firstX);
         delta = deltaColor(aColorFirst, aExpectedColor);
         if (delta > nMaxDelta)
             return false;
 
-        Color aColorLast  = pAccess->GetPixel(lastX,  y);
+        Color aColorLast  = pAccess->GetPixel(y, lastX);
         delta = deltaColor(aColorLast, aExpectedColor);
         if (delta > nMaxDelta)
             return false;
     }
     for (long x = firstX; x <= lastX; x++)
     {
-        Color aColorFirst = pAccess->GetPixel(x, firstY);
+        Color aColorFirst = pAccess->GetPixel(firstY, x);
         delta = deltaColor(aColorFirst, aExpectedColor);
         if (delta > nMaxDelta)
             return false;
 
-        Color aColorLast  = pAccess->GetPixel(x, lastY);
+        Color aColorLast  = pAccess->GetPixel(lastY, x);
         delta = deltaColor(aColorLast, aExpectedColor);
         if (delta > nMaxDelta)
             return false;
@@ -104,44 +105,44 @@ void JpegReaderTest::testReadRGB()
 {
     Bitmap aBitmap = loadJPG(getFullUrl("JPEGTestRGB.jpeg"));
     Size aSize = aBitmap.GetSizePixel();
-    CPPUNIT_ASSERT_EQUAL(8L, aSize.Width());
-    CPPUNIT_ASSERT_EQUAL(8L, aSize.Height());
+    CPPUNIT_ASSERT_EQUAL(12L, aSize.Width());
+    CPPUNIT_ASSERT_EQUAL(12L, aSize.Height());
 
     int nMaxDelta = 1; // still acceptable color error
-    CPPUNIT_ASSERT(checkRect(aBitmap, 0, Color(0xff, 0xff, 0xff), nMaxDelta));
-    CPPUNIT_ASSERT(checkRect(aBitmap, 1, Color(0xff, 0x00, 0x00), nMaxDelta));
-    CPPUNIT_ASSERT(checkRect(aBitmap, 2, Color(0x00, 0xff, 0x00), nMaxDelta));
-    CPPUNIT_ASSERT(checkRect(aBitmap, 3, Color(0x00, 0x00, 0xff), nMaxDelta));
+    CPPUNIT_ASSERT(checkRect(aBitmap, 0, 8, 8, Color(0xff, 0xff, 0xff), 
nMaxDelta));
+    CPPUNIT_ASSERT(checkRect(aBitmap, 1, 8, 8, Color(0xff, 0x00, 0x00), 
nMaxDelta));
+    CPPUNIT_ASSERT(checkRect(aBitmap, 2, 8, 8, Color(0x00, 0xff, 0x00), 
nMaxDelta));
+    CPPUNIT_ASSERT(checkRect(aBitmap, 3, 8, 8, Color(0x00, 0x00, 0xff), 
nMaxDelta));
 }
 
 void JpegReaderTest::testReadGray()
 {
     Bitmap aBitmap = loadJPG(getFullUrl("JPEGTestGray.jpeg"));
     Size aSize = aBitmap.GetSizePixel();
-    CPPUNIT_ASSERT_EQUAL(8L, aSize.Width());
-    CPPUNIT_ASSERT_EQUAL(8L, aSize.Height());
+    CPPUNIT_ASSERT_EQUAL(12L, aSize.Width());
+    CPPUNIT_ASSERT_EQUAL(12L, aSize.Height());
 
     aBitmap.Convert(BmpConversion::BMP_CONVERSION_24BIT); // convert to 24bit 
so we don't need to deal with palette
 
-    int nMaxDelta = 3;
-    CPPUNIT_ASSERT(checkRect(aBitmap, 0, Color(0xff, 0xff, 0xff), nMaxDelta));
-    CPPUNIT_ASSERT(checkRect(aBitmap, 1, Color(0x36, 0x36, 0x36), nMaxDelta));
-    CPPUNIT_ASSERT(checkRect(aBitmap, 2, Color(0xb6, 0xb6, 0xb6), nMaxDelta));
-    CPPUNIT_ASSERT(checkRect(aBitmap, 3, Color(0x12, 0x12, 0x12), nMaxDelta));
+    int nMaxDelta = 1;
+    CPPUNIT_ASSERT(checkRect(aBitmap, 0, 8, 8, Color(0xff, 0xff, 0xff), 
nMaxDelta));
+    CPPUNIT_ASSERT(checkRect(aBitmap, 1, 8, 8, Color(0x36, 0x36, 0x36), 
nMaxDelta));
+    CPPUNIT_ASSERT(checkRect(aBitmap, 2, 8, 8, Color(0xb6, 0xb6, 0xb6), 
nMaxDelta));
+    CPPUNIT_ASSERT(checkRect(aBitmap, 3, 8, 8, Color(0x12, 0x12, 0x12), 
nMaxDelta));
 }
 
 void JpegReaderTest::testReadCMYK()
 {
     Bitmap aBitmap = loadJPG(getFullUrl("JPEGTestCMYK.jpeg"));
     Size aSize = aBitmap.GetSizePixel();
-    CPPUNIT_ASSERT_EQUAL(8L, aSize.Width());
-    CPPUNIT_ASSERT_EQUAL(8L, aSize.Height());
-
-    int maxDelta = 7;
-    CPPUNIT_ASSERT(checkRect(aBitmap, 0, Color(0xff, 0xff, 0xff), maxDelta));
-    CPPUNIT_ASSERT(checkRect(aBitmap, 1, Color(0xff, 0x00, 0x00), maxDelta));
-    CPPUNIT_ASSERT(checkRect(aBitmap, 2, Color(0x00, 0xff, 0x00), maxDelta));
-    CPPUNIT_ASSERT(checkRect(aBitmap, 3, Color(0x00, 0x00, 0xff), maxDelta));
+    CPPUNIT_ASSERT_EQUAL(12L, aSize.Width());
+    CPPUNIT_ASSERT_EQUAL(12L, aSize.Height());
+
+    int maxDelta = 1;
+    CPPUNIT_ASSERT(checkRect(aBitmap, 0, 8, 8, Color(0xff, 0xff, 0xff), 
maxDelta));
+    CPPUNIT_ASSERT(checkRect(aBitmap, 1, 8, 8, Color(0xff, 0x00, 0x00), 
maxDelta));
+    CPPUNIT_ASSERT(checkRect(aBitmap, 2, 8, 8, Color(0x00, 0xff, 0x00), 
maxDelta));
+    CPPUNIT_ASSERT(checkRect(aBitmap, 3, 8, 8, Color(0x00, 0x00, 0xff), 
maxDelta));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(JpegReaderTest);
diff --git a/vcl/qa/cppunit/jpeg/data/JPEGTestCMYK.jpeg 
b/vcl/qa/cppunit/jpeg/data/JPEGTestCMYK.jpeg
index 5fc0c84..81cca02 100644
Binary files a/vcl/qa/cppunit/jpeg/data/JPEGTestCMYK.jpeg and 
b/vcl/qa/cppunit/jpeg/data/JPEGTestCMYK.jpeg differ
diff --git a/vcl/qa/cppunit/jpeg/data/JPEGTestGray.jpeg 
b/vcl/qa/cppunit/jpeg/data/JPEGTestGray.jpeg
index 2836dd9..014825f 100644
Binary files a/vcl/qa/cppunit/jpeg/data/JPEGTestGray.jpeg and 
b/vcl/qa/cppunit/jpeg/data/JPEGTestGray.jpeg differ
diff --git a/vcl/qa/cppunit/jpeg/data/JPEGTestRGB.jpeg 
b/vcl/qa/cppunit/jpeg/data/JPEGTestRGB.jpeg
index 8d51035..3cfe1dd 100644
Binary files a/vcl/qa/cppunit/jpeg/data/JPEGTestRGB.jpeg and 
b/vcl/qa/cppunit/jpeg/data/JPEGTestRGB.jpeg differ
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to