<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body bgcolor="#ffffff" text="#000000">
    On 04/13/2011 11:20 AM, Cyrille Berger Skott wrote:<br>
    <blockquote cite="mid:201104131120.40441.cberger@cberger.net"
      type="cite">
      <pre wrap="">Looks like it is breaking two unit tests:
<a class="moz-txt-link-freetext" href="http://my.cdash.org/viewTest.php?onlydelta&amp;buildid=177252">http://my.cdash.org/viewTest.php?onlydelta&amp;buildid=177252</a>
</pre>
    </blockquote>
    Phew.... this unit test stuff is starting to get really annoying :P<br>
    Every time i make some changes a couple of tests are breaking :D.<br>
    <br>
    Ok, to the first test "krita-plugin-format-xcf_test":<br>
    It compares an imported xcf file with a png file that contains the
    expected result.<br>
    Thats fine so far. I wanted to look what's going wrong, so i opened
    the xcf file in gimp and in krita...<br>
    but i couldn't see any difference. I looked again at the output of
    the unit test and there was written:<br>
        DEBUG : KisXCFTest::testFiles() Comparison failures: 
    ("subtract-multiply-masks.xcf: Pixel (28,10) has different values")<br>
    <br>
    So i looked what values the Pixel 28,10 has in gimp and what value
    it has in Krita:<br>
    <style type="text/css">p, li { white-space: pre-wrap; }</style>Krita 
    -&gt; RGB(216,214,214)<br>
    Gimp -&gt; RGB(216,213,214)<br>
    <br>
    Seems like the two pictures are compared to exact.<br>
    I would say it is completely acceptable if the result differs
    slightly to the expected result.<br>
    I think a tolerance of 1-2 units is fine (there shouldn't be any
    visual difference noticeable).<br>
    Otherwise we would limit ourself to implement every blending mode
    absolutely exact (without any optimization)<br>
    or to do it exactly like gimp/photoshop or whatever...<br>
    So my point is that we should compare just the visual result and not
    the exact pixel values (what doesn't work with floating point color
    spaces anyway).<br>
    We should compare the images with a tolerance here.<br>
    <br>
    The second test "krita-image-KisPainterTest":<br>
    I actually can't remember messing around with the selection...<br>
    But maybe i don't understand the test right<br>
    <br>
    the code:<br>
    <tt>/*<br>
    </tt><tt>Note: the bltSelection tests assume the following geometry:<br>
      <br>
    </tt><tt>0,0               0,30<br>
        +---------+------+<br>
        |  10,10  |      |<br>
        |    +----+      |<br>
        |    |####|      |<br>
        |    |####|      |<br>
        +----+----+      |<br>
        |       20,20    |<br>
        |                |<br>
        |                |<br>
        +----------------+<br>
                        30,30<br>
       */<br>
      void KisPainterTest::testPaintDeviceBltSelection(const
      KoColorSpace * cs)<br>
      {<br>
      <br>
          KisPaintDeviceSP dst = new KisPaintDevice(cs);<br>
      <br>
          KisPaintDeviceSP src = new KisPaintDevice(cs);<br>
          KoColor c(Qt::red, cs);<br>
          c.setOpacity(quint8(128));<br>
          src-&gt;fill(0, 0, 20, 20, c.data());<br>
      <br>
          QCOMPARE(src-&gt;exactBounds(), QRect(0, 0, 20, 20));<br>
      <br>
          KisSelectionSP selection = new KisSelection();<br>
          selection-&gt;getOrCreatePixelSelection()-&gt;select(QRect(10,
      10, 20, 20));<br>
          selection-&gt;updateProjection();<br>
          QCOMPARE(selection-&gt;selectedExactRect(), QRect(10, 10, 20,
      20));<br>
      <br>
          KisPainter painter(dst);<br>
          painter.setSelection(selection);<br>
      <br>
          painter.bitBlt(0, 0, src, 0, 0, 30, 30);<br>
          painter.end();<br>
      <br>
          QImage image = dst-&gt;convertToQImage(0);<br>
          image.save("blt_Selection_" + cs-&gt;name() + ".png");<br>
      <br>
          QCOMPARE(dst-&gt;exactBounds(), QRect(10, 10, 10, 10));<br>
      <br>
          const KoCompositeOp* op =
      cs-&gt;compositeOp(COMPOSITE_SUBTRACT);<br>
          if (op-&gt;id() == COMPOSITE_SUBTRACT) {<br>
      <br>
              KisPaintDeviceSP dst2 = new KisPaintDevice(cs);<br>
              KisPainter painter2(dst2);<br>
              painter2.setSelection(selection);<br>
              painter2.setCompositeOp(op);<br>
              painter2.bitBlt(0, 0, src, 0, 0, 30, 30);<br>
              painter2.end();<br>
      <br>
              QCOMPARE(dst2-&gt;exactBounds(), QRect(0, 0, 64, 64));<br>
          }<br>
      }</tt><br>
    <br>
    it fails here -&gt; QCOMPARE(dst2-&gt;exactBounds(), QRect(0, 0, 64,
    64)); with the line:<br>
    <br>
    <tt>FAIL!  : KisPainterTest::testPaintDeviceBltSelection() Compared
      values are not the same<br>
         Actual (dst2-&gt;exactBounds()): QRect(10,10 10x10)
      (bottomright 19,19)<br>
         Expected (QRect(0, 0, 64, 64)): QRect(0,0 64x64) (bottomright
      63,63)<br>
         Loc:
[/home/silvio/kde4/src/calligra/krita/image/tests/kis_painter_test.cpp(160)]<br>
    </tt><br>
    For me it seems that the second test creates a paint device (dst2)
    and sets a selection XYWH(10,10,20,20) then<br>
    it blits the source device (src) which is XYWH(0,0,20,20) to dst2
    with the statement "painter2.bitBlt(0, 0, src, 0, 0, 30, 30);".<br>
    but src is WH(20,20) not WH(30,30) ??<br>
    And then at the end the bounds of dst2 are expected to be
    XYWH(0,0,64,64) ??<br>
    Why should dst2 extend to WH(64,64) here?<br>
    <br>
    I actually don't know what i broke here...<br>
    <br>
  </body>
</html>