Makefile | 1 test/wmf/pass/TypeDetectionExample.wmf |binary test/wmf/pass/beef.wmf |binary test/wmf/pass/tdf88163.wmf |binary test/wmf/pass/vegetable.wmf |binary test/wmf/pass/visio_import_source.wmf |binary test/wmf/test.py | 46 +++++++++++++++++++++++++++++++++ 7 files changed, 47 insertions(+)
New commits: commit db25622001241fda6f2a1c3a1cdff4bc79c6b65e Author: Hossein <hoss...@libreoffice.org> AuthorDate: Sun Sep 12 00:31:38 2021 +0200 Commit: Hossein <hoss...@libreoffice.org> CommitDate: Sun Sep 12 00:43:37 2021 +0200 Add test and sample wmf files for wmf-dump.py Added test.py similar to the test.py for emf files, and samples from the LibreOffice Core source code and attachments from the Bugzilla. The test is added to the Makefile, so that it is invoked with 'make check'. To check: cd test/wmf && ./test.py Or simply: make check Change-Id: Ia2e819f48eae8cc4efc26411522ba1472bd19da4 Reviewed-on: https://gerrit.libreoffice.org/c/mso-dumper/+/121969 Tested-by: Hossein <hoss...@libreoffice.org> Reviewed-by: Hossein <hoss...@libreoffice.org> diff --git a/Makefile b/Makefile index 39312bb..a57d4fb 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ check: cd test/doc && ./test.py cd test/emf && ./test.py + cd test/wmf && ./test.py pycodestyle --ignore=E501 msodumper/binarystream.py pycodestyle --ignore=E501 msodumper/msometa.py pycodestyle --ignore=E501 doc-dump.py msodumper/doc*.py test/doc/test.py diff --git a/test/wmf/pass/TypeDetectionExample.wmf b/test/wmf/pass/TypeDetectionExample.wmf new file mode 100644 index 0000000..7ed7069 Binary files /dev/null and b/test/wmf/pass/TypeDetectionExample.wmf differ diff --git a/test/wmf/pass/beef.wmf b/test/wmf/pass/beef.wmf new file mode 100644 index 0000000..0947521 Binary files /dev/null and b/test/wmf/pass/beef.wmf differ diff --git a/test/wmf/pass/tdf88163.wmf b/test/wmf/pass/tdf88163.wmf new file mode 100644 index 0000000..edcab8a Binary files /dev/null and b/test/wmf/pass/tdf88163.wmf differ diff --git a/test/wmf/pass/vegetable.wmf b/test/wmf/pass/vegetable.wmf new file mode 100644 index 0000000..364d122 Binary files /dev/null and b/test/wmf/pass/vegetable.wmf differ diff --git a/test/wmf/pass/visio_import_source.wmf b/test/wmf/pass/visio_import_source.wmf new file mode 100644 index 0000000..88deac9 Binary files /dev/null and b/test/wmf/pass/visio_import_source.wmf differ diff --git a/test/wmf/test.py b/test/wmf/test.py new file mode 100755 index 0000000..831125e --- /dev/null +++ b/test/wmf/test.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +# -*- encoding: UTF-8 -*- +# +# 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] + "/../..") +wmf_dumper = __import__('wmf-dump') +from xml.etree import ElementTree +import unittest +import os + + +class Test(unittest.TestCase): + def dump(self, name): + try: + os.unlink("%s.wmf.xml" % name) + except OSError: + pass + sock = open("%s.wmf.xml" % name, "w") + saved = sys.stdout + sys.stdout = sock + wmf_dumper.main(["wmf-dumper", "%s.wmf" % name]) + sys.stdout = saved + sock.close() + tree = ElementTree.parse('%s.wmf.xml' % name) + self.root = tree.getroot() + # Make sure everything is dumped - so it can't happen that dump(a) == dump(b), but a != b. + self.assertEqual(0, len(self.root.findall('todo'))) + + def test_pass(self): + """This test just makes sure that all files in the 'pass' directory are + dumped without problems.""" + + for dirname, dirnames, filenames in os.walk('pass'): + for filename in filenames: + if filename.endswith(".wmf"): + self.dump(os.path.join(dirname, filename).replace('.wmf', '')) + +if __name__ == '__main__': + unittest.main() + +# vim:set filetype=python shiftwidth=4 softtabstop=4 expandtab: