[Mono-devel-list] Graphics merge-in status

Andrew Skiba andrews at mainsoft.com
Thu Aug 4 03:06:28 EDT 2005


Hello.

Yesterday I finished merging out our changes to System.Drawing. Vast
majority of changes were java-specific.

The next thing I want to do is to commit the drawing tests helper we
started to develop at Mainsoft.

I will create a directory under sys.drawing/test for this helper and
will commit the helper as is. It needs few changes, however, to be
usable for Mono. Today it checks TARGET_JVM to decide whether we are
creating reference results on dotnet, or run tests. Of course, it does
not suite Mono. I'd like to hear your ideas on how better to fix that.

Few words on the idea of this tool.

It is supposed to aid in writing tests that result in drawing. So there
is a class that provides 3 main features:

* Graphics property which can be used for any drawing operations
* Show method that opens a window with the result of the drawing to see
results manually
* Compare methods family - I will explain that in more details below.

So a typical test case will look like:

[Test]
public void DrawRectTest ()
{
	DrawingTest t = DrawingTest.Create (200, 200); //create helper
class instance with drawing area of this size

	t.Graphics.DrawRectangle (Pens.Blue, 10, 10, 150, 180);
	t.Show (); // optional
	Assert.IsTrue (t.Compare ());

	t.Graphics.DrawRectangle (Pens.Red, 50, 20, 190, 30);
	Assert.IsTrue (t.Compare ());
}

Now I will explain what Compare is all about.

When it's run on dotnet, Compare always returns true and as a side
effect it creates expected result named "DrawRectTest:X" where X is the
sequential number of the call inside DrawRectTest function. The name of
the function is extracted from the call stack.

When it later is run on java, Compare will find the expected result that
dotnet created and compare the FFT of the resulting bitmaps. If the
bitmaps were similar enough, it will return true. There is an overload
with tolerance parameter, for fine-tuning weird tests.

The comparing itself is done very approximately at this stage, actually
it's very easy to confuse the algorithm. It only calculates the sum of
the squares of all FFT values for every picture and compares the sums
for java and dotnet. This was done because it's very easy to keep one
number per expected result.

Any questions and suggestions are welcome.

Andrew.



More information about the Mono-devel-list mailing list