Hi

The problem is simple :
1) Writing unit test is boring
2) We do not have enough test of our style support
3) Writing unit test doesn't make you look great
4) Our current testing for OpenDocument support is quite poor
5) Unit tests aren't fancy
6) It's hard to have complete unit tests for something like OpenDocument.

So instead of writing unit tests, I decide to have something write them for me. 
Since slavery isn't allowed in most countries, that is not a valid solution.
Hence the solution I thought about : parse the OpenDocument scheme (available 
as 
RelaxNG), extract from it each possible style attribute, and dynamically 
generate and save style elements and see if they are loading and saving the 
right way.

During my travel tonight, I started sketching on my netbook a basic parser for 
Relax NG (using Python) and writing some stuff…
I just finished implementing the first version, using C++ of course (I don't 
want to bring yet another complicated beast in Calligra).
So far, it works perfectly on KoTableColumnStyle (which means it complains 
quite 
a lot with the current implementation…)

Here is the code specific to table column in my unit test :

void TestOpenDocumentStyle::testTableColumnStyle_data()
{
  QList<Attribute*> attributes = listAttributesFromRNGName
                                   ("style-table-column-properties-attlist");
  QTest::addColumn<Attribute*>("attribute");
  QTest::addColumn<QString>("value");
  foreach (Attribute *attribute, attributes) {
    foreach (QString value, attribute->listValues()) {
      QTest::newRow(attribute->name().toLatin1()) << attribute << value;
    }
  }
}

void TestOpenDocumentStyle::testTableColumnStyle()
{
  QFETCH(Attribute*, attribute);
  QFETCH(QString, value);
    
  basicTestFunction<KoTableColumnStyle>(KoGenStyle::TableColumnStyle, 
                                        "table-column", 
                                        attribute, 
                                        value);
}


And that's all. Every thing else (generating the style, testing it, parsing the 
RNG mess…) is generic. If the parser was a bit better, I could easily add 
support for other styles with just a few lines of code.

To make things more clear : this does not replace any current unit test. This 
does not control the document parsing.

I'm gonna commit this to master after I merge my words table style branch (it's 
fully functionnal, but still not complete, and I am tired of not being able to 
track my progress).

 Pierre

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
calligra-devel mailing list
calligra-devel@kde.org
https://mail.kde.org/mailman/listinfo/calligra-devel

Reply via email to