nss: upgrade to release 3.73
[LibreOffice.git] / sc / qa / uitest / textCase / textCase.py
blobafa98857e69267e259685ab40c6ececf0ae42979
1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 from uitest.framework import UITestCase
8 from uitest.uihelper.common import get_state_as_dict
9 from uitest.uihelper.common import select_pos
10 from uitest.uihelper.calc import enter_text_to_cell
11 from libreoffice.calc.document import get_cell_by_position
12 from libreoffice.uno.propertyvalue import mkPropertyValues
13 import org.libreoffice.unotest
14 import pathlib
15 def get_url_for_data_file(file_name):
16 return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
18 class textCase(UITestCase):
19 def test_text_case_switch(self):
20 calc_doc = self.ui_test.create_doc_in_start_center("calc")
21 xCalcDoc = self.xUITest.getTopFocusWindow()
22 gridwin = xCalcDoc.getChild("grid_window")
23 document = self.ui_test.get_component()
25 #enter data
26 enter_text_to_cell(gridwin, "A1", "hello world")
27 enter_text_to_cell(gridwin, "A2", "libre office")
28 enter_text_to_cell(gridwin, "A4", "free suite")
29 #select
30 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"}))
31 #Capitalize every word - CommandSent Name:.uno:ChangeCaseToTitleCase
32 self.xUITest.executeCommand(".uno:ChangeCaseToTitleCase")
33 #Verify
34 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello World")
35 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre Office")
36 self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "")
37 self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free Suite")
39 #Sentence case - CommandSent Name:.uno:ChangeCaseToSentenceCase
40 self.xUITest.executeCommand(".uno:ChangeCaseToSentenceCase")
42 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello world")
43 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre office")
44 self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "")
45 self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free suite")
47 #toggle case - CommandSent Name:.uno:ChangeCaseToToggleCase
48 self.xUITest.executeCommand(".uno:ChangeCaseToToggleCase")
49 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hELLO WORLD")
50 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "lIBRE OFFICE")
51 self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "")
52 self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "fREE SUITE")
54 #uppercase = CommandSent Name:.uno:ChangeCaseToUpper
55 self.xUITest.executeCommand(".uno:ChangeCaseToUpper")
56 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "HELLO WORLD")
57 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "LIBRE OFFICE")
58 self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "")
59 self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "FREE SUITE")
61 #lowercase - CommandSent Name:.uno:ChangeCaseToLower
62 self.xUITest.executeCommand(".uno:ChangeCaseToLower")
63 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hello world")
64 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "libre office")
65 self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "")
66 self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "free suite")
68 #cycle case = CommandSent Name:.uno:ChangeCaseRotateCase
69 self.xUITest.executeCommand(".uno:ChangeCaseRotateCase")
70 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello World")
71 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre Office")
72 self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "")
73 self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free Suite")
75 #select non continuous range
76 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B2"}))
77 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"}))
78 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A4:A5", "EXTEND":"1"}))
80 #lowercase - CommandSent Name:.uno:ChangeCaseToLower
81 self.xUITest.executeCommand(".uno:ChangeCaseToLower")
82 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hello world")
83 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "libre office")
84 self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "")
85 self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "free suite")
87 #Capitalize every word - CommandSent Name:.uno:ChangeCaseToTitleCase
88 self.xUITest.executeCommand(".uno:ChangeCaseToTitleCase")
89 #Verify
90 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello World")
91 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre Office")
92 self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "")
93 self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free Suite")
95 #Sentence case - CommandSent Name:.uno:ChangeCaseToSentenceCase
96 self.xUITest.executeCommand(".uno:ChangeCaseToSentenceCase")
98 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello world")
99 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre office")
100 self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "")
101 self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free suite")
103 #toggle case - CommandSent Name:.uno:ChangeCaseToToggleCase
104 self.xUITest.executeCommand(".uno:ChangeCaseToToggleCase")
105 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hELLO WORLD")
106 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "lIBRE OFFICE")
107 self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "")
108 self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "fREE SUITE")
110 #uppercase = CommandSent Name:.uno:ChangeCaseToUpper
111 self.xUITest.executeCommand(".uno:ChangeCaseToUpper")
112 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "HELLO WORLD")
113 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "LIBRE OFFICE")
114 self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "")
115 self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "FREE SUITE")
117 #lowercase - CommandSent Name:.uno:ChangeCaseToLower
118 self.xUITest.executeCommand(".uno:ChangeCaseToLower")
119 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hello world")
120 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "libre office")
121 self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "")
122 self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "free suite")
124 #cycle case = CommandSent Name:.uno:ChangeCaseRotateCase
125 self.xUITest.executeCommand(".uno:ChangeCaseRotateCase")
126 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello world")
127 self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre office")
128 self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "")
129 self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free suite")
130 self.ui_test.close_doc()
132 def test_tdf119155_Capitalize_Every_Word(self):
133 #Bug 119155 - Freeze after command format->text->Capitalize Every Word
134 calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf119155.xlsx"))
135 xCalcDoc = self.xUITest.getTopFocusWindow()
136 gridwin = xCalcDoc.getChild("grid_window")
137 document = self.ui_test.get_component()
138 #1. Open attached file
139 #2. Select cells from C2 to C14
140 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C2:C14"}))
141 #3. Go to menu: Format->Text->Capitalize Every Word
142 self.xUITest.executeCommand(".uno:ChangeCaseToTitleCase")
143 #Actual Results:Freezes LibreOffice
144 self.assertEqual(get_cell_by_position(document, 0, 2, 1).getString(), "Collagene Expert Targeted Wrinkle Corrector Unboxed 10 Ml")
145 self.assertEqual(get_cell_by_position(document, 0, 2, 13).getString(), "Vitamina Suractivee Hand Cream 400 Ml")
147 self.ui_test.close_doc()
149 def test_tdf119162_Cycle_Case(self):
150 #Bug 119162 - Format > Text > Cycle Case on attached example file hangs Calc reproducibly
151 calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf119162.xls"))
152 xCalcDoc = self.xUITest.getTopFocusWindow()
153 gridwin = xCalcDoc.getChild("grid_window")
154 document = self.ui_test.get_component()
155 #1.Open the attached .xls file
156 #2. Select column A
157 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
158 #3. Select [Format] > [Text] > [Cycle Case]
159 self.xUITest.executeCommand(".uno:ChangeCaseRotateCase")
160 self.xUITest.executeCommand(".uno:ChangeCaseToLower")
161 #Actual Results:Freezes LibreOffice
162 self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "test\n")
164 self.ui_test.close_doc()
165 # vim: set shiftwidth=4 softtabstop=4 expandtab: