summaryrefslogtreecommitdiffstats
path: root/sw/qa/uitest/librelogo
diff options
context:
space:
mode:
Diffstat (limited to 'sw/qa/uitest/librelogo')
-rw-r--r--sw/qa/uitest/librelogo/compile.py133
-rw-r--r--sw/qa/uitest/librelogo/run.py323
2 files changed, 456 insertions, 0 deletions
diff --git a/sw/qa/uitest/librelogo/compile.py b/sw/qa/uitest/librelogo/compile.py
new file mode 100644
index 0000000000..bf4668e8e3
--- /dev/null
+++ b/sw/qa/uitest/librelogo/compile.py
@@ -0,0 +1,133 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# 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/.
+#
+
+from uitest.framework import UITestCase
+
+import re
+
+class LibreLogoCompileTest(UITestCase):
+ LIBRELOGO_PATH = "vnd.sun.star.script:LibreLogo|LibreLogo.py$%s?language=Python&location=share"
+ LS = "#_@L_i_N_e@_#" # LibreLogo line separator for debug feature "jump to the bad LibreLogo program line"
+
+ 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 test_compile_librelogo(self):
+ # XScript interface to LibreLogo Python compiler
+ xCompile = self.getScript("__compil__")
+
+ for test in (
+ # BASE COMMANDS
+ ("FORWARD 1 forward 1 fd 1", "forward(1)\nforward(1)\nforward(1)"),
+ ("BACK 1 back 1 bk 1", "backward(1)\nbackward(1)\nbackward(1)"),
+ ("RIGHT 1 right 1 rt 1", "turnright(1)\nturnright(1)\nturnright(1)"),
+ ("LEFT 1 left 1 lt 1", "turnleft(1)\nturnleft(1)\nturnleft(1)"),
+ # COMMENTS
+ ("fd 1; comment\n; full-line comment", "forward(1)\n" + self.LS),
+ # MULTI-LINE COMMAND
+ ("LABEL ~\n10 + 10", "label(10 + 10)\n" + self.LS),
+ # UNIT SPECIFIERS
+ # check specifier "pt" (point)
+ ("fd 1pt", "forward(1)"),
+ # check specifier "pt" (point)
+ ("fd 0.5pt", "forward(0.5)"),
+ # check "in" (inch)
+ ("fd 1in", "forward(72.0)"),
+ # check "cm" (centimeter)
+ ("fd 1cm", "forward(%s)" % (1/(2.54/72))),
+ # check "mm" (millimeter)
+ ("fd 10mm", "forward(%s)" % (1/(2.54/72))),
+ # angle
+ ("rt 90°", "turnright(90)"),
+ # clock-position
+ ("rt 3h", "turnright(90.0)"),
+ # CONDITION
+ ("if a = 1 [ ]", "if a == 1 :\n __checkhalt__()"),
+ # with else
+ ("if a == 1 [ ] [ ]", "if a == 1 :\n __checkhalt__()\nelse:\n __checkhalt__()"),
+ # LOOPS
+ ("repeat 10 [ ]", "for REPCOUNT in range(1, 1+int(10 )):\n __checkhalt__()"),
+ # endless loop
+ ("repeat [ ]", "REPCOUNT0 = 1\nwhile True:\n __checkhalt__()\n REPCOUNT = REPCOUNT0\n REPCOUNT0 += 1"),
+ # loop in loop
+ ("repeat 10 [ repeat REPCOUNT [ a=1 ] ]", "for REPCOUNT in range(1, 1+int(10 )):\n __checkhalt__()\n for REPCOUNT in range(1, 1+int(REPCOUNT )):\n __checkhalt__()\n a=1"),
+ # while
+ ("WHILE REPCOUNT < 10 [ ]", "REPCOUNT2 = 1\nwhile REPCOUNT2 < 10 :\n __checkhalt__()\n REPCOUNT = REPCOUNT2\n REPCOUNT2 += 1"),
+ # for
+ ("FOR i in [1, 2, 3] [ ]", "REPCOUNT4 = 1\nfor i in [1, 2, 3] :\n __checkhalt__()\n REPCOUNT = REPCOUNT4\n REPCOUNT4 += 1"),
+ ("FOR i IN RANGE COUNT 'letters' [ ]", "REPCOUNT6 = 1\nfor i in range(len(u'letters'),) :\n __checkhalt__()\n REPCOUNT = REPCOUNT6\n REPCOUNT6 += 1"),
+ # PROCEDURE
+ ("TO x\nLABEL 2\nEND", "global x\ndef x():\n __checkhalt__()\n %s\n label(2)\n %s" % (((self.LS),)*2)),
+ # FUNCTION
+ ("TO x\nOUTPUT 3\nEND", "global x\ndef x():\n __checkhalt__()\n %s\n return 3\n %s" % (((self.LS),)*2)),
+ # PROCEDURE WITH ARGUMENTS
+ ("TO x y\nLABEL y\nEND\nx 25", "global x\ndef x(y):\n __checkhalt__()\n %s\n label(y)\n %s\n%s\nx(25)" % (((self.LS),)*3)),
+ ("TO x :y :z\nLABEL :y + :z\nEND\nx 25 26", "global x\ndef x(_y, _z):\n __checkhalt__()\n %s\n label(_y + _z)\n %s\n%s\nx(25, 26)" % (((self.LS),)*3)),
+ ("TO x :y :z\nLABEL :y + :z\nEND\nx 25 :w", "global x\ndef x(_y, _z):\n __checkhalt__()\n %s\n label(_y + _z)\n %s\n%s\nx(25, _w)" % (((self.LS),)*3)),
+ # UNICODE VARIABLE NAMES
+ ("Erdős=1", "Erd__u__0151s=1"),
+ # STRING CONSTANTS
+ ("LABEL \"label", "label(u'label')"),
+ ("LABEL “label”", "label(u'label')"),
+ ("LABEL 'label'", "label(u'label')"),
+ ("LABEL ‘label’", "label(u'label')"),
+ # check apostrophe and quote usage within strings
+ ("LABEL “label\’s”", "label(u'label’s')"),
+ ("LABEL ““It\’s quote\’s...\””", "label(u'“It’s quote’s...”')"),
+ ("LABEL ““It\\'s quote\\'s...\””", "label(u'“It\\'s quote\\'s...”')"),
+ # CONVERSION OF LOGO EXPRESSIONS
+ ("a=SIN 100 + COS 100", "a=sin(100 + cos(100))"),
+ ("a=SIN(101) + COS(101)", "a=sin(101) + cos(101)"),
+ ("a=(SIN 102) + (COS 102)", "a=(sin(102)) + (cos(102))"),
+ ("a=SIN 103 + COS 103 - SQRT 103", "a=sin(103 + cos(103 - sqrt(103)))"),
+ ("a=(SIN 104 + COS 104) - SQRT 104", "a=(sin(104 + cos(104))) - sqrt(104)"),
+ # SIN(x) is Python-like, SIN (x) is Logo-like syntax
+ ("a=SIN(105) + COS (105) - SQRT 105", "a=sin(105) + cos((105) - sqrt(105))"),
+ ("a=COUNT [1, 2, 3]", "a=len([1, 2, 3])"),
+ ("PRINT COUNT [1, 2, 3]", "Print(len([1, 2, 3]))"),
+ ("PRINT 'TEXT: ' + 'CHAR'[0] + ' TEXT2: ' + variable[-1]", "Print(u'TEXT: ' + u'CHAR'[0] + u' TEXT2: ' + variable[-1])"),
+ ("PRINT 'TEXT: ' + 'CHAR'[0][n] + ' TEXT2: ' + varia[len k][i+1]", "Print(u'TEXT: ' + u'CHAR'[0][n] + u' TEXT2: ' + varia[len(k)][i+1])"),
+ ("a=SQRT COUNT [1, 2, 3]", "a=sqrt(len([1, 2, 3]))"),
+ ("a=RANGE 1", "a=range(1,)"),
+ ("a=RANGE 1 10", "a=range(1, 10,)"),
+ ("a=RANGE 1 10 5", "a=range(1, 10, 5)"),
+ ("a=RANDOM 40 + 120", "a=Random(40 + 120)"),
+ ("a=RANDOM(40) + 120", "a=Random(40) + 120"),
+ ("a=RANDOM [1, 2, 3]", "a=Random([1, 2, 3])"),
+ ("PRINT RANDOM 40", "Print(Random(40))"),
+ ("FORWARD RANDOM 40", "forward(Random(40))"),
+ ("FORWARD 10 + RANDOM 40 + RANDOM 100", "forward(10 + Random(40 + Random(100)))"),
+ ("a=[sin 90 + cos 15, cos 100 * x, sqrt 25 * 25]", "a=[sin(90 + cos(15)), cos(100 * x), sqrt(25 * 25)]"),
+ ("a=[sin 90 + cos 15, cos 100 * x, sqrt 25 * 25]", "a=[sin(90 + cos(15)), cos(100 * x), sqrt(25 * 25)]"),
+ ("a=[sin(90) + cos 15, cos(100) * x, sqrt(25) * 25]", "a=[sin(90) + cos(15), cos(100) * x, sqrt(25) * 25]"),
+ ("TO x y z\nOUTPUT 3\nEND", "global x\ndef x(y, z):\n __checkhalt__()\n %s\n return 3\n %s" % (((self.LS),)*2)),
+ ("TO x\nOUTPUT 3\nEND", "global x\ndef x():\n __checkhalt__()\n %s\n return 3\n %s" % (((self.LS),)*2)),
+ ("TO f x y z\nOUTPUT x+y+z\nEND\na = [-sin -len f [-cos 45, 6] -len [1, 2, 3] -sin -90", "global f\ndef f(x, y, z):\n __checkhalt__()\n %s\n return x+y+z\n %s\n%s\na = [-sin(-len(f([-cos(45), 6], -len([1, 2, 3]), -sin(-90))))" % (((self.LS),)*3)),
+ ("TO f x y z\nOUTPUT x+y+z\nEND\na = [sin len f [cos 45, 6] [1, 2, 3] sin 90", "global f\ndef f(x, y, z):\n __checkhalt__()\n %s\n return x+y+z\n %s\n%s\na = [sin(len(f([cos(45), 6], [1, 2, 3], sin(90))))" % (((self.LS),)*3)),
+ ("TO f x y z\nLABEL x+y+z\nEND\nf len [1, cos 2, [65]] sqrt len [1, 2, 3, 4] sin 90 * cos 270", "global f\ndef f(x, y, z):\n __checkhalt__()\n %s\n label(x+y+z)\n %s\n%s\nf(len([1, cos(2), [65]]), sqrt(len([1, 2, 3, 4])), sin(90 * cos(270)))" % (((self.LS),)*3)),
+ ("TO f x y z\nLABEL x+y+z\nEND\nf len([1, cos 2, [65]]) sqrt(len [1, 2, 3, 4]) sin(90) * cos 270", "global f\ndef f(x, y, z):\n __checkhalt__()\n %s\n label(x+y+z)\n %s\n%s\nf(len([1, cos(2), [65]]), sqrt(len([1, 2, 3, 4])), sin(90) * cos(270))" % (((self.LS),)*3)),
+ ("TO f x y z\nLABEL x+y+z\nEND\nf (len [1, cos 2, [65]]) (sqrt len [1, 2, 3, 4]) (sin 90) * (cos 270)", "global f\ndef f(x, y, z):\n __checkhalt__()\n %s\n label(x+y+z)\n %s\n%s\nf((len([1, cos(2), [65]])), (sqrt(len([1, 2, 3, 4]))), (sin(90)) * (cos(270)))" % (((self.LS),)*3)),
+ # arbitrary order of function definitions and calls
+ ("f 1 1 f 2 2\nTO f x y\nPRINT x + y\nEND", "global f\nf(1, 1)\nf(2, 2)\n%s\ndef f(x, y):\n __checkhalt__()\n %s\n Print(x + y)\n %s" % (((self.LS),)*3)),
+ ):
+ compiled = xCompile.invoke((test[0],), (), ())[0]
+ self.assertEqual(test[1], re.sub(r'(\n| +\n)+', '\n', re.sub(r'\( ', '(', compiled)).strip())
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/librelogo/run.py b/sw/qa/uitest/librelogo/run.py
new file mode 100644
index 0000000000..54e0032160
--- /dev/null
+++ b/sw/qa/uitest/librelogo/run.py
@@ -0,0 +1,323 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# 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/.
+#
+
+from uitest.framework import UITestCase
+from uitest.uihelper.common import type_text
+from com.sun.star.awt.FontSlant import NONE as __Slant_NONE__
+from com.sun.star.awt.FontSlant import ITALIC as __Slant_ITALIC__
+from com.sun.star.awt.FontUnderline import NONE as __Underline_NONE__
+from com.sun.star.awt.FontUnderline import SINGLE as __Underline_SINGLE__
+from com.sun.star.awt.FontStrikeout import NONE as __Strikeout_NONE__
+from com.sun.star.awt.FontStrikeout import SINGLE as __Strikeout_SINGLE__
+
+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):
+ with self.ui_test.create_doc_in_start_center("writer") as document:
+ 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.replace('\r\n', '\n'), "\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, "")
+
+ # function definitions and calls can be in arbitrary order
+ document.Text.String = """
+; dragon curve
+TO x n
+IF n = 0 [ STOP ]
+x n-1
+RIGHT 90
+y n-1 ; it worked only as "y(n-1)"
+FORWARD 10
+END
+
+TO y n
+IF n = 0 [ STOP ]
+FORWARD 10
+x n-1
+LEFT 90
+y n-1
+END
+
+PICTURE ; start new line draw
+x 3 ; draw only a few levels
+"""
+ self.logo("run")
+ # wait for LibreLogo program termination
+ while xIsAlive.invoke((), (), ())[0]:
+ pass
+ # new shape + previous two ones = 3
+# disable unreliable test. Depending on how busy the machine is, this may produce 3 or 4
+# self.assertEqual(document.DrawPage.getCount(), 3)
+
+ def check_label(self, hasCustomLock):
+ sLock = "CLEARSCREEN "
+ if hasCustomLock:
+ sLock = sLock + "SLEEP -1 "
+ with self.ui_test.create_doc_in_start_center("writer") as document:
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
+ # to check the state of LibreLogo program execution
+ xIsAlive = self.getScript("__is_alive__")
+
+ #1 run a program with basic LABEL command
+
+ type_text(xWriterEdit, sLock + "LABEL 'Hello, World!'")
+ self.logo("run")
+ # wait for LibreLogo program termination
+ while xIsAlive.invoke((), (), ())[0]:
+ pass
+
+ # turtle and text shape
+ self.assertEqual(document.DrawPage.getCount(), 2)
+ textShape = document.DrawPage.getByIndex(1)
+ # text in the text shape
+ self.assertEqual(textShape.getString(), "Hello, World!")
+
+ #2 check italic, bold, underline + red and blue formatting
+
+ document.Text.String = sLock + "LABEL '<i><red>Hello</red>, <bold><blue>W<u>orld</blue></bold>!</i></u>'"
+ self.logo("run")
+ # wait for LibreLogo program termination
+ while xIsAlive.invoke((), (), ())[0]:
+ pass
+
+ # turtle and text shape
+ self.assertEqual(document.DrawPage.getCount(), 2)
+ textShape = document.DrawPage.getByIndex(1)
+ # text in the text shape
+ self.assertEqual(textShape.getString(), "Hello, World!")
+ # check portion formatting
+ c = textShape.createTextCursor()
+ c.gotoStart(False)
+ # before character "H"
+ self.assertEqual(c.CharPosture, __Slant_ITALIC__) # cursive
+ self.assertEqual(c.CharUnderline, __Underline_NONE__) # no underline
+ self.assertEqual(c.CharWeight, 100) # normal weight
+ self.assertEqual(c.CharColor, 0xFF0000) # red color
+ # after character " "
+ c.goRight(6, False)
+ self.assertEqual(c.CharPosture, __Slant_ITALIC__) # cursive
+ self.assertEqual(c.CharUnderline, __Underline_NONE__) # no underline
+ self.assertEqual(c.CharWeight, 100) # normal weight
+ self.assertEqual(c.CharColor, 0x000000) # black color
+ # after character "W"
+ c.goRight(2, False)
+ self.assertEqual(c.CharPosture, __Slant_ITALIC__) # cursive
+ self.assertEqual(c.CharUnderline, __Underline_NONE__) # no underline
+ self.assertEqual(c.CharWeight, 150) # bold
+ self.assertEqual(c.CharColor, 0x0000FF) # blue color
+ # 9th: after character "o"
+ c.goRight(1, False)
+ self.assertEqual(c.CharPosture, __Slant_ITALIC__) # cursive
+ self.assertEqual(c.CharUnderline, __Underline_SINGLE__) # underline
+ self.assertEqual(c.CharWeight, 150) # bold
+ self.assertEqual(c.CharColor, 0x0000FF) # blue color
+ # last: after character "!"
+ c.gotoEnd(False)
+ self.assertEqual(c.CharPosture, __Slant_ITALIC__) # cursive
+ self.assertEqual(c.CharUnderline, __Underline_SINGLE__) # underline
+ self.assertEqual(c.CharWeight, 100) # normal weight
+ self.assertEqual(c.CharColor, 0x000000) # black color
+
+ #2 check strike out, sub, sup, font name and font size formatting
+
+ document.Text.String = (
+ sLock + "FONTFAMILY 'Linux Biolinum G' FONTSIZE 12 " +
+ "LABEL '<s>x</s>, <sub>x</sub>, <sup>x</sup>, " +
+ "<FONTFAMILY Liberation Sans>x</FONTFAMILY>, " +
+ "<FONTHEIGHT 20>x</FONTHEIGHT>...'" )
+
+ self.logo("run")
+ # wait for LibreLogo program termination
+ while xIsAlive.invoke((), (), ())[0]:
+ pass
+
+ # turtle and text shape
+ self.assertEqual(document.DrawPage.getCount(), 2)
+ textShape = document.DrawPage.getByIndex(1)
+ # text in the text shape
+ self.assertEqual(textShape.getString(), "x, x, x, x, x...")
+ # check portion formatting
+ c = textShape.createTextCursor()
+ c.gotoStart(False)
+ # check portion formatting
+ c = textShape.createTextCursor()
+ c.gotoStart(False)
+
+ # strike out
+ self.assertEqual(c.CharStrikeout, __Strikeout_SINGLE__) # strike out
+ c.goRight(4, False)
+
+ # subscript
+ self.assertEqual(c.CharStrikeout, __Strikeout_NONE__) # no strike out
+ self.assertEqual(c.CharEscapement, -14000) # magic number for default subscript, see DFLT_ESC_AUTO_SUB
+ self.assertEqual(c.CharEscapementHeight, 58) # size in percent
+ c.goRight(3, False)
+
+ # superscript
+ self.assertEqual(c.CharEscapement, 14000) # magic number for default superscript, see DFLT_ESC_AUTO_SUPER
+ self.assertEqual(c.CharEscapementHeight, 58) # size in percent
+ c.goRight(3, False)
+
+ # font family
+ self.assertEqual(c.CharEscapement, 0) # no superscript
+ self.assertEqual(c.CharEscapementHeight, 100) # no superscript
+ self.assertEqual(c.CharFontName, "Liberation Sans") # new font family
+ c.goRight(3, False)
+
+ # font size
+ self.assertEqual(c.CharFontName, "Linux Biolinum G") # default font family
+ self.assertEqual(c.CharHeight, 20) # new font size
+ c.goRight(3, False)
+
+ # default font size
+ self.assertEqual(c.CharHeight, 12)
+
+ #3 check colors
+
+ document.Text.String = ( sLock +
+ "LABEL '<red>x</red>, <BLUE>x</BLUE>, " + # check ignoring case
+ "<FONTCOLOR GREEN>x</FONTCOLOR>, " + # check with command
+ "<FONTCOLOR 0x0000FF>x, " + # check with hexa code
+ "<FILLCOLOR ORANGE>x</FILLCOLOR>, " + # blue text with orange highlighting
+ "<FILLCOLOR 0xFF00FF>x</FILLCOLOR>" + # blue text with purple highlighting
+ "...</FONTCOLOR>'" )
+
+ self.logo("run")
+ # wait for LibreLogo program termination
+ while xIsAlive.invoke((), (), ())[0]:
+ pass
+
+ # turtle and text shape
+ self.assertEqual(document.DrawPage.getCount(), 2)
+ textShape = document.DrawPage.getByIndex(1)
+ # text in the text shape
+ self.assertEqual(textShape.getString(), "x, x, x, x, x, x...")
+ # check portion formatting
+ c = textShape.createTextCursor()
+ c.gotoStart(False)
+ # check portion formatting
+ c = textShape.createTextCursor()
+ c.gotoStart(False)
+
+ self.assertEqual(c.CharColor, 0xFF0000) # red
+ self.assertEqual(c.CharBackColor, -1) # transparent highlight
+ c.goRight(4, False)
+
+ self.assertEqual(c.CharColor, 0x0000FF) # blue
+ self.assertEqual(c.CharBackColor, -1) # transparent highlight
+ c.goRight(3, False)
+
+ self.assertEqual(c.CharColor, 0x008000) # green
+ self.assertEqual(c.CharBackColor, -1) # transparent highlight
+ c.goRight(3, False)
+
+ self.assertEqual(c.CharColor, 0x0000FF) # blue
+ self.assertEqual(c.CharBackColor, -1) # transparent highlight
+ c.goRight(3, False)
+
+ self.assertEqual(c.CharColor, 0x0000FF) # blue
+ self.assertEqual(c.CharBackColor, 0xFFA500) # orange highlight
+ c.goRight(3, False)
+
+ self.assertEqual(c.CharColor, 0x0000FF) # blue
+ self.assertEqual(c.CharBackColor, 0xFF00FF) # purple highlight
+ c.goRight(3, False)
+
+ self.assertEqual(c.CharColor, 0x0000FF) # blue
+ self.assertEqual(c.CharBackColor, -1) # transparent highlight
+
+ #4 check font features
+
+ document.Text.String = (
+ sLock + "FONTFAMILY 'Linux Biolinum G' " +
+ "LABEL 'a <smcp>smcp <pnum>1<onum>1</pnum> 1</onum>1</smcp>...'" )
+
+ self.logo("run")
+ # wait for LibreLogo program termination
+ while xIsAlive.invoke((), (), ())[0]:
+ pass
+
+ # turtle and text shape
+ self.assertEqual(document.DrawPage.getCount(), 2)
+ textShape = document.DrawPage.getByIndex(1)
+ # text in the text shape
+ self.assertEqual(textShape.getString(), "a smcp 11 11...")
+ # check portion formatting
+ c = textShape.createTextCursor()
+ c.gotoStart(False)
+ # check portion formatting
+ c = textShape.createTextCursor()
+ c.gotoStart(False)
+
+ self.assertEqual(c.CharFontName, "Linux Biolinum G")
+ c.goRight(3, False)
+ self.assertEqual(c.CharFontName, "Linux Biolinum G:smcp")
+ c.goRight(5, False)
+ self.assertEqual(c.CharFontName, "Linux Biolinum G:smcp&pnum")
+ c.goRight(1, False)
+ self.assertEqual(c.CharFontName, "Linux Biolinum G:smcp&pnum&onum")
+ c.goRight(2, False)
+ self.assertEqual(c.CharFontName, "Linux Biolinum G:smcp&onum")
+ c.goRight(1, False)
+ self.assertEqual(c.CharFontName, "Linux Biolinum G:smcp")
+
+ def test_LABEL(self):
+ self.check_label(False)
+
+ def test_custom_lock(self):
+ self.check_label(True)
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab: