cstester - a tool for testing loading and painting of documents

Thorsten Zachmann t.zachmann at zagge.de
Wed Jan 19 05:01:02 GMT 2011


On Tuesday, January 18, 2011 14:51:25 Cyrille Berger Skott wrote:
> 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.

I think you are right that using this way should be platform independent. 
Comapred to the image approach where you can look at and see if it shows 
correctly with the representation you have chosen that is not possible 
directly. 

There might be still a small part which is not coverd to be platform 
independed and that is the usage of the dpi value but I'm not sure about that.

> (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 :) )

maybe cou can convince Hanna to work on a different mode for the tool that does 
exactly that?

Thorsten



More information about the calligra-devel mailing list