cstester - a tool for testing loading and painting of documents

Cyrille Berger Skott cberger at cberger.net
Tue Jan 18 13:51:25 GMT 2011


Hi,

I had a similar idea. But instead of testing the exact rendering, which is 
rather fragile, my idea was to implement a special QPaintEngine (and 
associated QPaintDevice), that would record as text the drawing commands.

The idea is that the actual drawing on screen is not up to our responsability, 
it would be a Qt matter, what is important from a calligra point of view is 
that the call to QPainter's API is correct.

The way I see it would be outputing text that would look like this:
"LINE 12.0 -12.1 34.3 2.3 QPEN(255,0,0)"

Which means that a red line has been drawn from (12.0,-12.1) to (34.3, 2.3).

And in the QPaintEngine it would be implemented as:

void QPaintEngine::drawLines ( const QLineF * lines, int lineCount )
{
   for(int i = 0; i < lineCount; ++i)
   {
      addText( QString("LINE %1 %2 %3 %4 %5")
				.arg(lines[i]->x1())
				.arg(lines[i]->y1())
				.arg(lines[i]->x2())
				.arg(lines[i]->y2())
				.arg(currentPenText()) );
   }
}

And then you could use this QPaintEngine/QPaintDevice with QPainter, and 
basically test anything that need to be drawn. That could range from unit 
testing KoShape::paint, to testing the rendering of document.

This approach also has the advantage that it should be platform independent, 
meaning that anyone could run the test suite, and it would not break on update 
of the testing platform.

(on a side note, my intention was to have Hanna works on this when she is more 
at ease with Calligra code, but if you want to take that idea, I would not 
mind, and will find her something else to do :) )

-- 
Cyrille Berger Skott



More information about the calligra-devel mailing list