Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/4294

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/94/4294/1

Migrate CheckFields unit test to python

Change-Id: Ia765b37888b4095a735015e792f06fc89201d1a3
---
M solenv/gbuild/PythonTest.mk
M sw/PythonTest_sw_python.mk
A sw/qa/python/check_fields.py
M unotest/source/python/org/libreoffice/unotest.py
4 files changed, 61 insertions(+), 0 deletions(-)



diff --git a/solenv/gbuild/PythonTest.mk b/solenv/gbuild/PythonTest.mk
index eaa8757..012d642 100644
--- a/solenv/gbuild/PythonTest.mk
+++ b/solenv/gbuild/PythonTest.mk
@@ -40,6 +40,7 @@
                ($(gb_PythonTest_PRECOMMAND) \
                $(if $(G_SLICE),G_SLICE=$(G_SLICE)) \
                $(if $(GLIBCXX_FORCE_NEW),GLIBCXX_FORCE_NEW=$(GLIBCXX_FORCE_NEW)) \
+               $(DEFS) \
                URE_BOOTSTRAP=vnd.sun.star.pathname:$(gb_DEVINSTALLROOT)/program/fundamentalrc \
                PYTHONPATH=$(PYPATH) \
                UserInstallation="$(call gb_Helper_make_url,$(OUTDIR)/unittest)" \
@@ -60,6 +61,11 @@
 
 $(eval $(call gb_Module_register_target,$(call gb_PythonTest_get_target,$(1)),$(call 
gb_PythonTest_get_clean_target,$(1))))
 $(call gb_Helper_make_userfriendly_targets,$(1),PythonTest)
+
+endef
+
+define gb_PythonTest_set_defs
+$(call gb_PythonTest_get_target,$(1)) : DEFS := $(2)
 
 endef
 
@@ -94,6 +100,7 @@
 
 endef
 
+gb_PythonTest_set_defs :=
 gb_PythonTest_add_modules :=
 gb_PythonTest_use_customtarget :=
 
diff --git a/sw/PythonTest_sw_python.mk b/sw/PythonTest_sw_python.mk
index cbddfc5..ecf57ba 100644
--- a/sw/PythonTest_sw_python.mk
+++ b/sw/PythonTest_sw_python.mk
@@ -9,7 +9,12 @@
 
 $(eval $(call gb_PythonTest_PythonTest,sw_python))
 
+$(eval $(call gb_PythonTest_set_defs,sw_python,\
+    TDOC="$(SRCDIR)/sw/qa/complex/writer/testdocuments" \
+))
+
 $(eval $(call gb_PythonTest_add_modules,sw_python,$(SRCDIR)/sw/qa/python,\
+       check_fields \
        get_expression \
        set_expression \
        var_fields \
diff --git a/sw/qa/python/check_fields.py b/sw/qa/python/check_fields.py
new file mode 100644
index 0000000..180ae8f
--- /dev/null
+++ b/sw/qa/python/check_fields.py
@@ -0,0 +1,32 @@
+import unittest
+from org.libreoffice.unotest import UnoInProcess
+
+class CheckFields(unittest.TestCase):
+    _uno = None
+    _xDoc = None
+
+    @classmethod
+    def setUpClass(cls):
+        cls._uno = UnoInProcess()
+        cls._uno.setUp()
+        cls._xDoc = cls._uno.openWriterTemplateDoc("fdo39694.ott")
+
+    @classmethod
+    def tearDownClass(cls):
+        cls._uno.tearDown()
+
+    def test_fdo39694_load(self):
+        placeholders = ["<Kadr1>", "<Kadr2>", "<Kadr3>", "<Kadr4>", "<Pnname>", "<Pvname>", 
"<Pgeboren>"]
+        xDoc = self.__class__._xDoc
+        xEnumerationAccess = xDoc.getTextFields()
+        xFieldEnum = xEnumerationAccess.createEnumeration()
+        while xFieldEnum.hasMoreElements():
+            xField = xFieldEnum.nextElement()
+            if xField.supportsService("com.sun.star.text.TextField.JumpEdit"):
+                xAnchor = xField.getAnchor()
+                readContent = xAnchor.getString()
+                self.assertTrue(readContent in placeholders,
+                                "field %s not contained" % readContent)
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/unotest/source/python/org/libreoffice/unotest.py 
b/unotest/source/python/org/libreoffice/unotest.py
index 3ec016a..883d3a4 100644
--- a/unotest/source/python/org/libreoffice/unotest.py
+++ b/unotest/source/python/org/libreoffice/unotest.py
@@ -31,6 +31,11 @@
     print("  URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc")
     raise
 
+try:
+    from urllib.parse import quote
+except ImportError:
+    from urllib import quote
+
 ### utilities ###
 
 def mkPropertyValue(name, value):
@@ -181,6 +186,18 @@
         assert(self.xDoc)
         return self.xDoc
 
+    def openWriterTemplateDoc(self, file):
+        assert(self.xContext)
+        smgr = self.getContext().ServiceManager
+        desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.getContext())
+        props = [("Hidden", True), ("ReadOnly", False), ("AsTemplate", True)]
+        loadProps = tuple([mkPropertyValue(name, value) for (name, value) in props])
+        path = os.getenv("TDOC")
+        url = "file://" + quote(path) + "/" + quote(file)
+        self.xDoc = desktop.loadComponentFromURL(url, "_blank", 0, loadProps)
+        assert(self.xDoc)
+        return self.xDoc
+
     def checkProperties(self, obj, dict, test):
         for k,v in dict.items():
             obj.setPropertyValue(k, v)

-- 
To view, visit https://gerrit.libreoffice.org/4294
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia765b37888b4095a735015e792f06fc89201d1a3
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: David Ostrovsky <David.Ostrovsky@gmx.de>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.