[Libreoffice-commits] .: test/charprops.rtf test/doc
Miklos Vajna
vmiklos at kemper.freedesktop.org
Sun Nov 25 03:10:22 PST 2012
test/charprops.rtf | 3 ---
test/doc/charprops.doc |binary
test/doc/charprops.rtf | 3 +++
test/doc/test.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 49 insertions(+), 3 deletions(-)
New commits:
commit e9b96b012a7ab20446a40c190240a00986ee8e10
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Sun Nov 25 11:59:55 2012 +0100
add some initial real test for doc
diff --git a/test/charprops.rtf b/test/charprops.rtf
deleted file mode 100644
index d0a2a3a..0000000
--- a/test/charprops.rtf
+++ /dev/null
@@ -1,3 +0,0 @@
-{\rtf1
-Hello \b world!\par
-}
diff --git a/test/doc/charprops.doc b/test/doc/charprops.doc
new file mode 100644
index 0000000..1c2b5d8
Binary files /dev/null and b/test/doc/charprops.doc differ
diff --git a/test/doc/charprops.rtf b/test/doc/charprops.rtf
new file mode 100644
index 0000000..d0a2a3a
--- /dev/null
+++ b/test/doc/charprops.rtf
@@ -0,0 +1,3 @@
+{\rtf1
+Hello \b world!\par
+}
diff --git a/test/doc/test.py b/test/doc/test.py
new file mode 100755
index 0000000..52874cc
--- /dev/null
+++ b/test/doc/test.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+import sys
+sys.path.append(sys.path[0]+"/../..")
+sys.path.append(sys.path[0]+"/../../src")
+doc_dumper = __import__('doc-dump')
+from xml.etree import ElementTree
+import unittest
+import os
+
+class Test(unittest.TestCase):
+ def dump(self, name):
+ try:
+ os.unlink("%s.doc.xml" % name)
+ except OSError:
+ pass
+ sock = open("%s.doc.xml" % name, "w")
+ saved = sys.stdout
+ sys.stdout = sock
+ doc_dumper.main(["doc-dumper", "%s.doc" % name])
+ sys.stdout = saved
+ sock.close()
+ tree = ElementTree.parse('%s.doc.xml' % name)
+ return tree.getroot()
+
+ def test_charprops(self):
+ root = self.dump('charprops')
+
+ runs = root.findall('./stream[@name="WordDocument"]/fib/fibRgFcLcbBlob/lcbPlcfBteChpx/plcBteChpx/aFC/aPnBteChpx/chpxFkp/rgfc')
+ self.assertEqual(2, len(runs))
+
+ self.assertEqual('Hello ', runs[0].findall('./transformed')[0].attrib['value'])
+ self.assertEqual(0, len(runs[0].findall("./chpx/prl/sprm[@name='sprmCFBold']")))
+
+ self.assertEqual('world!\\x0D', runs[1].findall('./transformed')[0].attrib['value'])
+ self.assertEqual(1, len(runs[1].findall("./chpx/prl/sprm[@name='sprmCFBold']")))
+
+if __name__ == '__main__':
+ unittest.main()
+
+# vim:set filetype=python shiftwidth=4 softtabstop=4 expandtab:
More information about the Libreoffice-commits
mailing list