Debian Codegraph @

sc/qa/uitest/calc_tests8/tdf126248_fontname_checking.py

raw symbols SCIP
1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
2 #
3 # This file is part of the LibreOffice project.
4 #
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/.
8 #
9
10 from uitest.framework import UITestCase
11 from uitest.uihelper.common import get_state_as_dict
12 from libreoffice.uno.propertyvalue import mkPropertyValues
13 from uitest.uihelper.calc import enter_text_to_cell
14 from uitest.uihelper.common import select_pos
15 from uitest.uihelper.common import select_by_text
16
17 class tdf126248(UITestCase):
18
19 def assertFontName(self, gridwin, fontName):
20
21 #Open the sidebar
22 self.xUITest.executeCommand(".uno:Sidebar")
23 gridwin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "TextPropertyPanel"}))
24
25 xCalcDoc = self.xUITest.getTopFocusWindow()
26
27 xFontName = xCalcDoc.getChild("fontnamecombobox")
28 self.ui_test.wait_until_property_is_updated(xFontName, "Text", fontName)
29 self.assertEqual(fontName, get_state_as_dict(xFontName)['Text'])
30
31 #Close the sidebar
32 self.xUITest.executeCommand(".uno:Sidebar")
33
34 def changeLocalSetting(self, language):
35 with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialog:
36 xPages = xDialog.getChild("pages")
37 xLanguageEntry = xPages.getChild('2')
38 xLanguageEntry.executeAction("EXPAND", tuple())
39 xxLanguageEntryGeneralEntry = xLanguageEntry.getChild('0')
40 xxLanguageEntryGeneralEntry.executeAction("SELECT", tuple())
41
42 localeSetting = xDialog.getChild("localesetting")
43 select_by_text(localeSetting, language)
44 self.ui_test.wait_until_property_is_updated(localeSetting, 'SelectEntryText', language)
45 self.assertEqual(language, get_state_as_dict(localeSetting)['SelectEntryText'])
46
47 def test_tdf126248(self):
48
49 with self.ui_test.create_doc_in_start_center("calc"):
50
51 try:
52 self.changeLocalSetting("Chinese (traditional)")
53
54 with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog:
55 xTabs = xDialog.getChild("tabcontrol")
56 select_pos(xTabs, "1")
57
58 # Get current font names from the Format Cell dialog
59 westFontName = get_state_as_dict(xDialog.getChild("edWestFontName"))['Text']
60 eastFontName = get_state_as_dict(xDialog.getChild("edCJKFontName"))['Text']
61
62 xCalcDoc = self.xUITest.getTopFocusWindow()
63 gridwin = xCalcDoc.getChild("grid_window")
64
65 enter_text_to_cell(gridwin, "A1", "Test")
66
67 # Without the fix in place, this test would have failed here
68 self.assertFontName(gridwin, westFontName)
69
70 enter_text_to_cell(gridwin, "B1", "測試")
71
72 self.assertFontName(gridwin, eastFontName)
73
74 finally:
75 self.changeLocalSetting("English (USA)")
76
77 enter_text_to_cell(gridwin, "C1", "Test")
78
79 self.assertFontName(gridwin, westFontName)
80
81 enter_text_to_cell(gridwin, "D1", "測試")
82
83 self.assertFontName(gridwin, eastFontName)
84
85 # vim: set shiftwidth=4 softtabstop=4 expandtab: