Move setting of LD_LIBRARY_PATH closer to invocation of cppunittester
[LibreOffice.git] / sc / qa / uitest / statistics / covariance.py
blobcec5a1d7855a5dfc0dfe414725ad5b7dcb0604e1
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/.
9 from uitest.framework import UITestCase
10 from uitest.uihelper.calc import enter_text_to_cell
12 from libreoffice.calc.document import get_cell_by_position
13 from libreoffice.uno.propertyvalue import mkPropertyValues
16 class covariance(UITestCase):
17 def test_statistic_covariance_column(self):
18 with self.ui_test.create_doc_in_start_center("calc") as document:
19 xCalcDoc = self.xUITest.getTopFocusWindow()
20 gridwin = xCalcDoc.getChild("grid_window")
21 #fill data
22 enter_text_to_cell(gridwin, "A1", "Maths")
23 enter_text_to_cell(gridwin, "A2", "47")
24 enter_text_to_cell(gridwin, "A3", "36")
25 enter_text_to_cell(gridwin, "A4", "40")
26 enter_text_to_cell(gridwin, "A5", "39")
27 enter_text_to_cell(gridwin, "A7", "47")
28 enter_text_to_cell(gridwin, "A8", "29")
29 enter_text_to_cell(gridwin, "A9", "27")
30 enter_text_to_cell(gridwin, "A10", "57")
31 enter_text_to_cell(gridwin, "A11", "56")
32 enter_text_to_cell(gridwin, "A12", "57")
33 enter_text_to_cell(gridwin, "A13", "26")
35 enter_text_to_cell(gridwin, "B1", "Physics")
36 enter_text_to_cell(gridwin, "B2", "67")
37 enter_text_to_cell(gridwin, "B3", "68")
38 enter_text_to_cell(gridwin, "B4", "65")
39 enter_text_to_cell(gridwin, "B5", "64")
40 enter_text_to_cell(gridwin, "B6", "38")
41 enter_text_to_cell(gridwin, "B7", "84")
42 enter_text_to_cell(gridwin, "B8", "80")
43 enter_text_to_cell(gridwin, "B9", "49")
44 enter_text_to_cell(gridwin, "B10", "49")
45 enter_text_to_cell(gridwin, "B11", "33")
47 enter_text_to_cell(gridwin, "C1", "Biology")
48 enter_text_to_cell(gridwin, "C2", "33")
49 enter_text_to_cell(gridwin, "C3", "42")
50 enter_text_to_cell(gridwin, "C4", "44")
51 enter_text_to_cell(gridwin, "C5", "60")
52 enter_text_to_cell(gridwin, "C6", "43")
53 enter_text_to_cell(gridwin, "C7", "62")
54 enter_text_to_cell(gridwin, "C8", "51")
55 enter_text_to_cell(gridwin, "C9", "40")
56 enter_text_to_cell(gridwin, "C10", "12")
57 enter_text_to_cell(gridwin, "C11", "60")
58 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C13"}))
59 with self.ui_test.execute_modeless_dialog_through_command(".uno:CovarianceDialog") as xDialog:
60 xinputrangeedit = xDialog.getChild("input-range-edit")
61 xoutputrangeedit = xDialog.getChild("output-range-edit")
62 xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio")
64 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
65 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
66 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$C$13"}))
67 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
68 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
69 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"}))
70 xgroupedbycolumnsradio.executeAction("CLICK", tuple())
71 #Verify
72 self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Covariances")
73 self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Column 1")
74 self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Column 2")
75 self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Column 3")
77 self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "Column 1")
78 self.assertEqual(round(get_cell_by_position(document, 0, 6, 1).getValue(),11), 126.80991735537)
79 self.assertEqual(round(get_cell_by_position(document, 0, 6, 2).getValue(),12), -61.444444444444)
80 self.assertEqual(round(get_cell_by_position(document, 0, 6, 3).getValue()), -32)
82 self.assertEqual(get_cell_by_position(document, 0, 7, 0).getString(), "Column 2")
83 self.assertEqual(round(get_cell_by_position(document, 0, 7, 2).getValue(),2), 258.41)
84 self.assertEqual(round(get_cell_by_position(document, 0, 7, 3).getValue(),2), 53.11)
86 self.assertEqual(get_cell_by_position(document, 0, 8, 0).getString(), "Column 3")
87 self.assertEqual(round(get_cell_by_position(document, 0, 8, 3).getValue(),2), 204.61)
89 #undo
90 self.xUITest.executeCommand(".uno:Undo")
91 self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "")
93 # test cancel button
94 with self.ui_test.execute_modeless_dialog_through_command(".uno:CovarianceDialog", close_button="cancel"):
95 pass
97 def test_statistic_covariance_row(self):
98 with self.ui_test.create_doc_in_start_center("calc") as document:
99 xCalcDoc = self.xUITest.getTopFocusWindow()
100 gridwin = xCalcDoc.getChild("grid_window")
101 #fill data
102 enter_text_to_cell(gridwin, "A1", "Maths")
103 enter_text_to_cell(gridwin, "A2", "Physics")
104 enter_text_to_cell(gridwin, "A3", "Biology")
106 enter_text_to_cell(gridwin, "B1", "47")
107 enter_text_to_cell(gridwin, "B2", "67")
108 enter_text_to_cell(gridwin, "B3", "33")
110 enter_text_to_cell(gridwin, "C1", "36")
111 enter_text_to_cell(gridwin, "C2", "68")
112 enter_text_to_cell(gridwin, "C3", "42")
114 enter_text_to_cell(gridwin, "D1", "40")
115 enter_text_to_cell(gridwin, "D2", "65")
116 enter_text_to_cell(gridwin, "D3", "44")
118 enter_text_to_cell(gridwin, "E1", "39")
119 enter_text_to_cell(gridwin, "E2", "64")
120 enter_text_to_cell(gridwin, "E3", "60")
122 enter_text_to_cell(gridwin, "F2", "38")
123 enter_text_to_cell(gridwin, "F3", "43")
125 enter_text_to_cell(gridwin, "G1", "47")
126 enter_text_to_cell(gridwin, "G2", "84")
127 enter_text_to_cell(gridwin, "G3", "62")
129 enter_text_to_cell(gridwin, "H1", "29")
130 enter_text_to_cell(gridwin, "H2", "80")
131 enter_text_to_cell(gridwin, "H3", "51")
133 enter_text_to_cell(gridwin, "I1", "27")
134 enter_text_to_cell(gridwin, "I2", "49")
135 enter_text_to_cell(gridwin, "I3", "40")
137 enter_text_to_cell(gridwin, "J1", "57")
138 enter_text_to_cell(gridwin, "J2", "49")
139 enter_text_to_cell(gridwin, "J3", "12")
141 enter_text_to_cell(gridwin, "K1", "56")
142 enter_text_to_cell(gridwin, "K2", "33")
143 enter_text_to_cell(gridwin, "K3", "60")
145 enter_text_to_cell(gridwin, "L1", "57")
147 enter_text_to_cell(gridwin, "M1", "26")
149 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:M3"}))
150 with self.ui_test.execute_modeless_dialog_through_command(".uno:CovarianceDialog") as xDialog:
151 xinputrangeedit = xDialog.getChild("input-range-edit")
152 xoutputrangeedit = xDialog.getChild("output-range-edit")
153 xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio")
155 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
156 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
157 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$M$3"}))
158 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
159 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
160 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$A$7"}))
161 xgroupedbyrowsradio.executeAction("CLICK", tuple())
162 #Verify
163 self.assertEqual(get_cell_by_position(document, 0, 0, 6).getString(), "Covariances")
164 self.assertEqual(get_cell_by_position(document, 0, 0, 7).getString(), "Row 1")
165 self.assertEqual(get_cell_by_position(document, 0, 0, 8).getString(), "Row 2")
166 self.assertEqual(get_cell_by_position(document, 0, 0, 9).getString(), "Row 3")
168 self.assertEqual(get_cell_by_position(document, 0, 1, 6).getString(), "Row 1")
169 self.assertEqual(round(get_cell_by_position(document, 0, 1, 7).getValue(),10), 126.8099173554)
170 self.assertEqual(round(get_cell_by_position(document, 0, 1, 8).getValue(),12), -61.444444444444)
171 self.assertEqual(round(get_cell_by_position(document, 0, 1, 9).getValue()), -32)
173 self.assertEqual(get_cell_by_position(document, 0, 2, 6).getString(), "Row 2")
174 self.assertEqual(round(get_cell_by_position(document, 0, 2, 8).getValue(),2), 258.41)
175 self.assertEqual(round(get_cell_by_position(document, 0, 2, 9).getValue(),2), 53.11)
177 self.assertEqual(get_cell_by_position(document, 0, 3, 6).getString(), "Row 3")
178 self.assertEqual(round(get_cell_by_position(document, 0, 3, 9).getValue(),2), 204.61)
180 #undo
181 self.xUITest.executeCommand(".uno:Undo")
182 self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "")
184 # vim: set shiftwidth=4 softtabstop=4 expandtab: