1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 from uitest
.framework
import UITestCase
11 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
12 from uitest
.uihelper
.common
import get_state_as_dict
13 from uitest
.uihelper
.common
import select_pos
15 # specialcharacters.ui
16 class specialCharacter(UITestCase
):
18 def test_tdf56363(self
):
19 with self
.ui_test
.create_doc_in_start_center("writer"):
20 xWriterDoc
= self
.xUITest
.getTopFocusWindow()
22 # Insert a font including a font feature into the font name combobox
23 xFontName
= xWriterDoc
.getChild("fontnamecombobox")
24 fontName
= get_state_as_dict(xFontName
)["Text"]
25 xFontName
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+A"}))
26 xFontName
.executeAction("TYPE", mkPropertyValues({"TEXT": fontName
+ ":smcp"}))
27 xFontName
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
29 # Open special character dialog and check selected font name
30 with self
.ui_test
.execute_dialog_through_command(".uno:InsertSymbol", close_button
="cancel") as xDialog
:
31 xComboFont
= xDialog
.getChild("fontlb")
32 # Without the fix in place, no font would be selected
33 self
.assertEqual(get_state_as_dict(xComboFont
)["Text"], fontName
)
35 def test_special_character(self
):
36 with self
.ui_test
.create_doc_in_start_center("writer"):
38 with self
.ui_test
.execute_dialog_through_command(".uno:InsertSymbol", close_button
="cancel") as xDialog
:
39 xCharSet
= xDialog
.getChild("showcharset") # default charset
41 xCharSet
.executeAction("SELECT", mkPropertyValues({"COLUMN": "1", "ROW": "4"})) # digit 4 selected
43 xHexText
= xDialog
.getChild("hexvalue")
44 xDecText
= xDialog
.getChild("decimalvalue")
46 self
.assertEqual(get_state_as_dict(xHexText
)["Text"], "34") # check the values Hex and decimal
47 self
.assertEqual(get_state_as_dict(xDecText
)["Text"], "52")
50 with self
.ui_test
.execute_dialog_through_command(".uno:InsertSymbol", close_button
="cancel") as xDialog
:
52 xComboFont
= xDialog
.getChild("fontlb")
53 select_pos(xComboFont
, "0") # select font
54 xComboFont2
= xDialog
.getChild("subsetlb")
55 select_pos(xComboFont2
, "0") # select font subset
57 xSearchText
= xDialog
.getChild("search") # test search textBox
58 xSearchText
.executeAction("TYPE", mkPropertyValues({"TEXT": "d"}))
59 xSearchText
.executeAction("TYPE", mkPropertyValues({"TEXT": "i"}))
60 xSearchText
.executeAction("TYPE", mkPropertyValues({"TEXT": "g"}))
61 xSearchText
.executeAction("TYPE", mkPropertyValues({"TEXT": "i"}))
62 xSearchText
.executeAction("TYPE", mkPropertyValues({"TEXT": "t"}))
63 xSearchText
.executeAction("TYPE", mkPropertyValues({"TEXT": " "}))
64 xSearchText
.executeAction("TYPE", mkPropertyValues({"TEXT": "f"}))
65 xSearchText
.executeAction("TYPE", mkPropertyValues({"TEXT": "o"}))
66 xSearchText
.executeAction("TYPE", mkPropertyValues({"TEXT": "u"}))
67 xSearchText
.executeAction("TYPE", mkPropertyValues({"TEXT": "r"}))
69 # works locally and linux_gcc_release_64, but fails at linux_clang_dbgutil_64.
70 # Markus: Actually after a round of debugging I think the problem is actually that the test depends on the used font.
71 # Therefore, if the font is not available or not selected by default the test fails.
72 # xCharSet = xDialog.getChild("searchcharset") #another charset -> search charset
73 # xCharSet.executeAction("SELECT", mkPropertyValues({"COLUMN": "0", "ROW": "0"})) #digit 4 selected, we have only one result;
74 # sleep(1) #try sleep here
75 # xCharSet.executeAction("SELECT", mkPropertyValues({"COLUMN": "0", "ROW": "0"})) #try it twice, because it works at local,but fail on gerrit
76 ##gerrit:self.assertEqual(get_state_as_dict(xHexText)["Text"], "34") # check the values for digit 4; AssertionError: '1' != '34'
78 # xHexText = xDialog.getChild("hexvalue")
79 # xDecText = xDialog.getChild("decimalvalue")
80 # self.assertEqual(get_state_as_dict(xHexText)["Text"], "34") # check the values for digit 4
81 # self.assertEqual(get_state_as_dict(xDecText)["Text"], "52")
83 # xAddFavBtn = xDialog.getChild("favbtn")
84 # xAddFavBtn.executeAction("CLICK", tuple()) # Add to favorites button
86 # xInsrBtn = xDialog.getChild("insert")
87 # xInsrBtn.executeAction("CLICK", tuple()) # Insert to document
89 # self.assertEqual(document.Text.String[0:1], "4") # check inserted character
91 # self.xUITest.executeCommand(".uno:Undo")
92 # self.xUITest.executeCommand(".uno:Redo") #undo, redo
94 # self.assertEqual(document.Text.String[0:1], "4") # check inserted character after undo, redo
97 # vim: set shiftwidth=4 softtabstop=4 expandtab: