summaryrefslogtreecommitdiff
path: root/xmloff/qa/unit
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2013-09-30 15:23:35 +0300
committerTor Lillqvist <tml@collabora.com>2013-09-30 17:40:53 +0300
commitc1015fdd51909495cefdc0258c3899cd73d4d2df (patch)
tree901f0fb94a93dbd614c18d3320bcfa414672e441 /xmloff/qa/unit
parent32e0f451d69b68d69a4aa91c271b81ea6264d3c1 (diff)
Add hack to optionally get stable ODF output from the same input
To be used in regression testing and similar scenarios, where the output ODF is *not* intended to be further manipulated in LibreOffice. An environment variable LIBO_ONEWAY_STABLE_ODF_EXPORT is used to toggle this behaviour. I am not 100% sure whether the generated ODF with the hack toggled on is even fully correct, but correctness is not the purpose of the hack anyway. Two classes of issues handled: 1) Automatic style names and 2) use of randomness. For class 1), when the hack toggle is in effect, we generate the names at first as strings based on all the properties of the style, and sort them based on those, and then rename them (for brevity in the output) to the "normal" form of a short prefix plus a number (like "P12"). Sure, it would have been better to just figure out *why* the automatic style naming currently is not stable in the first place, but outputs the styles in different order (with some styles being assigned different numbers) in separate invokations of LibreOffice), but I was unable to understand that. Possibly this code could be used in all cases, except that it does break some unit test (can't recall which right now). I don't know whether that is simply because the unit test assumes too much knowledge of the internal workings of the automatic style name generation, or whether the generated ODF is actually invalid. For 2), I found a handful of places where randomness was used to generated various kinds of identifiers in ODF output. I changed those to just use large (64-bit) non-overlapping integers instead. I assume there *is* a point in the original code in each case that explains why randomness is needed, so the hack definitely needs to be optional and used only for the above mentioned scenarios. Change-Id: I17b657197e38bcf24abdfe61ad4a277f4339eeae
Diffstat (limited to 'xmloff/qa/unit')
-rw-r--r--xmloff/qa/unit/uxmloff.cxx6
1 files changed, 5 insertions, 1 deletions
diff --git a/xmloff/qa/unit/uxmloff.cxx b/xmloff/qa/unit/uxmloff.cxx
index a0bd4306226b..8dfa5021ed99 100644
--- a/xmloff/qa/unit/uxmloff.cxx
+++ b/xmloff/qa/unit/uxmloff.cxx
@@ -75,7 +75,11 @@ void Test::testAutoStylePool()
OUString aName = xPool->Add( XML_STYLE_FAMILY_TEXT_PARAGRAPH, "", aProperties );
// not that interesting but worth checking
- CPPUNIT_ASSERT_MESSAGE( "style / naming changed", aName == "Bob1" );
+ bool bHack = (getenv("LIBO_ONEWAY_STABLE_ODF_EXPORT") != NULL);
+ if (bHack)
+ CPPUNIT_ASSERT_MESSAGE( "style / naming changed", aName == "Bob" );
+ else
+ CPPUNIT_ASSERT_MESSAGE( "style / naming changed", aName == "Bob1" );
// find ourselves again:
OUString aSameName = xPool->Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, "", aProperties );