summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2018-10-23 23:08:44 +0200
committerLászló Németh <nemeth@numbertext.org>2018-10-25 08:22:42 +0200
commit4712b830f82a1de6ce3d7dddbe80a0f83947b968 (patch)
tree093adb3ea36445f9243d2ee65090405930903aef
parenttdf#120038 Fix broken svg galler arrow A25 (diff)
downloadcore-4712b830f82a1de6ce3d7dddbe80a0f83947b968.tar.gz
core-4712b830f82a1de6ce3d7dddbe80a0f83947b968.zip
LibreLogo: add unit tests
for program running and command name expansion, and for following fixes: tdf#106792: regression in line length and continuous line drawing tdf#100941: line breaking by "magic wand" tdf#120422: program lines are different paragraphs by "magic wand" Also add function __is_alive__() to LibreLogo.py to check LibreLogo program termination via XScript API. Change-Id: If884b3fd608a6e8077be853eb2dd17fbdfff2011 Reviewed-on: https://gerrit.libreoffice.org/62263 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--librelogo/source/LibreLogo/LibreLogo.py3
-rw-r--r--sw/Module_sw.mk1
-rw-r--r--sw/UITest_librelogo.mk16
-rw-r--r--sw/qa/uitest/librelogo/run.py74
4 files changed, 94 insertions, 0 deletions
diff --git a/librelogo/source/LibreLogo/LibreLogo.py b/librelogo/source/LibreLogo/LibreLogo.py
index 356ed97f551a..0dc5d7ea2ed7 100644
--- a/librelogo/source/LibreLogo/LibreLogo.py
+++ b/librelogo/source/LibreLogo/LibreLogo.py
@@ -516,6 +516,9 @@ class LogoProgram(threading.Thread):
with __lock__:
__thread__ = None
+# to check LibreLogo program termination (in that case, return value is False)
+def __is_alive__():
+ return __thread__ != None
def __encodestring__(m):
__strings__.append(re.sub("\\[^\\]", "", m.group(2)))
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index f55eb121cc5f..174f3247a8f8 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -143,6 +143,7 @@ $(eval $(call gb_Module_add_uicheck_targets,sw,\
UITest_table \
UITest_findReplace \
UITest_chapterNumbering \
+ UITest_librelogo \
))
endif
diff --git a/sw/UITest_librelogo.mk b/sw/UITest_librelogo.mk
new file mode 100644
index 000000000000..35e53641e782
--- /dev/null
+++ b/sw/UITest_librelogo.mk
@@ -0,0 +1,16 @@
+# This file is part of the LibreOffice project.
+#
+# 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/.
+#
+
+$(eval $(call gb_UITest_UITest,librelogo))
+
+$(eval $(call gb_UITest_add_modules,librelogo,$(SRCDIR)/sw/qa/uitest,\
+ librelogo/ \
+))
+
+$(eval $(call gb_UITest_set_defs,librelogo, \
+ TDOC="$(SRCDIR)/sw/qa/uitest/writer_tests/data" \
+))
diff --git a/sw/qa/uitest/librelogo/run.py b/sw/qa/uitest/librelogo/run.py
new file mode 100644
index 000000000000..5d36c5d14e7b
--- /dev/null
+++ b/sw/qa/uitest/librelogo/run.py
@@ -0,0 +1,74 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# 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/.
+
+from uitest.framework import UITestCase
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import get_state_as_dict, type_text
+
+import time
+from uitest.debug import sleep
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import select_pos
+
+class LibreLogoTest(UITestCase):
+ LIBRELOGO_PATH = "vnd.sun.star.script:LibreLogo|LibreLogo.py$%s?language=Python&location=share"
+
+ def createMasterScriptProviderFactory(self):
+ xServiceManager = self.xContext.ServiceManager
+ return xServiceManager.createInstanceWithContext(
+ "com.sun.star.script.provider.MasterScriptProviderFactory",
+ self.xContext)
+
+ def getScript(self, command):
+ xMasterScriptProviderFactory = self.createMasterScriptProviderFactory()
+ document = self.ui_test.get_component()
+ xScriptProvider = xMasterScriptProviderFactory.createScriptProvider(document)
+ xScript = xScriptProvider.getScript(self.LIBRELOGO_PATH %command)
+ self.assertIsNotNone(xScript, "xScript was not loaded")
+ return xScript
+
+ def logo(self, command):
+ self.xUITest.executeCommand(self.LIBRELOGO_PATH %command)
+
+ def test_librelogo(self):
+ self.ui_test.create_doc_in_start_center("writer")
+ document = self.ui_test.get_component()
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
+ # to check the state of LibreLogo program execution
+ xIsAlive = self.getScript("__is_alive__")
+
+ # run a program with basic drawing commands FORWARD and RIGHT
+ # using their abbreviated names FD and RT
+ type_text(xWriterEdit, "fd 100 rt 45 fd 100")
+ self.logo("run")
+ # wait for LibreLogo program termination
+ while xIsAlive.invoke((), (), ())[0]:
+ pass
+ # check shape count for
+ # a) program running:
+ # - turtle shape: result of program start
+ # - line shape: result of turtle drawing
+ # b) continuous line drawing (the regression
+ # related to the fix of tdf#106792 resulted shorter line
+ # segments than the turtle path and non-continuous line
+ # drawing, ie. in this example, three line shapes
+ # instead of a single one. See its fix in
+ # commit 502e8785085f9e8b54ee383080442c2dcaf95b15)
+ self.assertEqual(document.DrawPage.getCount(), 2)
+
+ # check formatting by "magic wand"
+ self.logo("__translate__")
+ # a) check expansion of abbreviated commands : fd -> FORWARD, rt -> RIGHT,
+ # b) check line breaking (fix for tdf#100941: new line instead of the text "\" and "n")
+ self.assertEqual(document.Text.String, "\nFORWARD 100 RIGHT 45 FORWARD 100")
+ # c) check usage of real paragraphs instead of line break (tdf#120422)
+ # first paragraph is empty (for working page break)
+ self.assertEqual(document.Text.createEnumeration().nextElement().String, "")
+
+ self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab: