Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / qa / uitest / statistics / descriptiveStatistics.py
blob112803418dac37604288cb163d16ee7c986c49d3
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_sheet_from_doc
12 from libreoffice.calc.conditional_format import get_conditional_format_from_sheet
13 from uitest.debug import sleep
14 from libreoffice.calc.document import get_cell_by_position
15 from libreoffice.uno.propertyvalue import mkPropertyValues
17 class descriptiveStatistics(UITestCase):
18 def test_descriptive_statistics(self):
19 calc_doc = self.ui_test.create_doc_in_start_center("calc")
20 xCalcDoc = self.xUITest.getTopFocusWindow()
21 gridwin = xCalcDoc.getChild("grid_window")
22 document = self.ui_test.get_component()
23 #fill data
24 enter_text_to_cell(gridwin, "A1", "Math")
25 enter_text_to_cell(gridwin, "A2", "47")
26 enter_text_to_cell(gridwin, "A3", "36")
27 enter_text_to_cell(gridwin, "A4", "40")
28 enter_text_to_cell(gridwin, "A5", "39")
29 enter_text_to_cell(gridwin, "A7", "47")
30 enter_text_to_cell(gridwin, "A8", "29")
31 enter_text_to_cell(gridwin, "A9", "27")
32 enter_text_to_cell(gridwin, "A10", "57")
33 enter_text_to_cell(gridwin, "A11", "56")
34 enter_text_to_cell(gridwin, "A12", "57")
35 enter_text_to_cell(gridwin, "A13", "26")
38 enter_text_to_cell(gridwin, "B1", "Physics")
39 enter_text_to_cell(gridwin, "B2", "67")
40 enter_text_to_cell(gridwin, "B3", "68")
41 enter_text_to_cell(gridwin, "B4", "65")
42 enter_text_to_cell(gridwin, "B5", "64")
43 enter_text_to_cell(gridwin, "B6", "38")
44 enter_text_to_cell(gridwin, "B7", "84")
45 enter_text_to_cell(gridwin, "B8", "80")
46 enter_text_to_cell(gridwin, "B9", "49")
47 enter_text_to_cell(gridwin, "B10", "49")
48 enter_text_to_cell(gridwin, "B11", "33")
50 enter_text_to_cell(gridwin, "C1", "Biology")
51 enter_text_to_cell(gridwin, "C2", "33")
52 enter_text_to_cell(gridwin, "C3", "42")
53 enter_text_to_cell(gridwin, "C4", "44")
54 enter_text_to_cell(gridwin, "C5", "60")
55 enter_text_to_cell(gridwin, "C6", "43")
56 enter_text_to_cell(gridwin, "C7", "62")
57 enter_text_to_cell(gridwin, "C8", "51")
58 enter_text_to_cell(gridwin, "C9", "40")
59 enter_text_to_cell(gridwin, "C10", "12")
60 enter_text_to_cell(gridwin, "C11", "60")
62 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C13"}))
63 self.ui_test.execute_modeless_dialog_through_command(".uno:DescriptiveStatisticsDialog")
64 xDialog = self.xUITest.getTopFocusWindow()
65 xinputrangeedit = xDialog.getChild("input-range-edit")
66 xoutputrangeedit = xDialog.getChild("output-range-edit")
68 xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio")
69 xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio")
71 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
72 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
73 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$C$13"}))
75 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
76 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
77 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$F$1"}))
79 xgroupedbyrowsradio.executeAction("CLICK", tuple())
80 xgroupedbycolumnsradio.executeAction("CLICK", tuple())
82 xOKBtn = xDialog.getChild("ok")
83 self.ui_test.close_dialog_through_button(xOKBtn)
85 #Verify
86 self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString() , "Mean")
87 self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString() , "Standard Error")
88 self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString() , "Mode")
89 self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString() , "Median")
90 self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString() , "First Quartile")
91 self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString() , "Third Quartile")
92 self.assertEqual(get_cell_by_position(document, 0, 5, 7).getString() , "Variance")
93 self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString() , "Standard Deviation")
94 self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString() , "Kurtosis")
95 self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString() , "Skewness")
96 self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString() , "Range")
97 self.assertEqual(get_cell_by_position(document, 0, 5, 12).getString() , "Minimum")
98 self.assertEqual(get_cell_by_position(document, 0, 5, 13).getString() , "Maximum")
99 self.assertEqual(get_cell_by_position(document, 0, 5, 14).getString() , "Sum")
100 self.assertEqual(get_cell_by_position(document, 0, 5, 15).getString() , "Count")
102 self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString() , "Column 1")
103 self.assertEqual(round(get_cell_by_position(document, 0, 6, 1).getValue(),12) , 41.909090909091)
104 self.assertEqual(round(get_cell_by_position(document, 0, 6, 2).getValue(),13) , 3.5610380137731)
105 self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue() , 47)
106 self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue() , 40)
107 self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue() , 32.5)
108 self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue() , 51.5)
109 self.assertEqual(round(get_cell_by_position(document, 0, 6, 7).getValue(),11) , 139.49090909091)
110 self.assertEqual(round(get_cell_by_position(document, 0, 6, 8).getValue(),12) , 11.810626955878)
111 self.assertEqual(round(get_cell_by_position(document, 0, 6, 9).getValue(),13) , -1.4621677980825)
112 self.assertEqual(round(get_cell_by_position(document, 0, 6, 10).getValue(),14) , 0.01524095329036)
113 self.assertEqual(get_cell_by_position(document, 0, 6, 11).getValue() , 31)
114 self.assertEqual(get_cell_by_position(document, 0, 6, 12).getValue() , 26)
115 self.assertEqual(get_cell_by_position(document, 0, 6, 13).getValue() , 57)
116 self.assertEqual(get_cell_by_position(document, 0, 6, 14).getValue() , 461)
117 self.assertEqual(get_cell_by_position(document, 0, 6, 15).getValue() , 11)
119 self.assertEqual(get_cell_by_position(document, 0, 7, 0).getString() , "Column 2")
120 self.assertEqual(round(get_cell_by_position(document, 0, 7, 1).getValue(),1) , 59.7)
121 self.assertEqual(round(get_cell_by_position(document, 0, 7, 2).getValue(),14) , 5.35837869343164)
122 self.assertEqual(get_cell_by_position(document, 0, 7, 3).getValue() , 49)
123 self.assertEqual(get_cell_by_position(document, 0, 7, 4).getValue() , 64.5)
124 self.assertEqual(get_cell_by_position(document, 0, 7, 5).getValue() , 49)
125 self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue() , 67.75)
126 self.assertEqual(round(get_cell_by_position(document, 0, 7, 7).getValue(),11) , 287.12222222222)
127 self.assertEqual(round(get_cell_by_position(document, 0, 7, 8).getValue(),12) , 16.944681236961)
128 self.assertEqual(round(get_cell_by_position(document, 0, 7, 9).getValue(),14) , -0.94159887458526)
129 self.assertEqual(round(get_cell_by_position(document, 0, 7, 10).getValue(),13) , -0.2226426904338)
130 self.assertEqual(get_cell_by_position(document, 0, 7, 11).getValue() , 51)
131 self.assertEqual(get_cell_by_position(document, 0, 7, 12).getValue() , 33)
132 self.assertEqual(get_cell_by_position(document, 0, 7, 13).getValue() , 84)
133 self.assertEqual(get_cell_by_position(document, 0, 7, 14).getValue() , 597)
134 self.assertEqual(get_cell_by_position(document, 0, 7, 15).getValue() , 10)
136 self.assertEqual(get_cell_by_position(document, 0, 8, 0).getString() , "Column 3")
137 self.assertEqual(get_cell_by_position(document, 0, 8, 1).getValue() , 44.7)
138 self.assertEqual(round(get_cell_by_position(document, 0, 8, 2).getValue(),13) , 4.7680650629416)
139 self.assertEqual(get_cell_by_position(document, 0, 8, 3).getValue() , 60)
140 self.assertEqual(get_cell_by_position(document, 0, 8, 4).getValue() , 43.5)
141 self.assertEqual(get_cell_by_position(document, 0, 8, 5).getValue() , 40.5)
142 self.assertEqual(get_cell_by_position(document, 0, 8, 6).getValue() , 57.75)
143 self.assertEqual(round(get_cell_by_position(document, 0, 8, 7).getValue(),11) , 227.34444444444)
144 self.assertEqual(round(get_cell_by_position(document, 0, 8, 8).getValue(),11) , 15.07794563077)
145 self.assertEqual(round(get_cell_by_position(document, 0, 8, 9).getValue(),12) , 1.418052718986)
146 self.assertEqual(round(get_cell_by_position(document, 0, 8, 10).getValue(),14) , -0.97668033725691)
147 self.assertEqual(get_cell_by_position(document, 0, 8, 11).getValue() , 50)
148 self.assertEqual(get_cell_by_position(document, 0, 8, 12).getValue() , 12)
149 self.assertEqual(get_cell_by_position(document, 0, 8, 13).getValue() , 62)
150 self.assertEqual(get_cell_by_position(document, 0, 8, 14).getValue() , 447)
151 self.assertEqual(get_cell_by_position(document, 0, 8, 15).getValue() , 10)
152 #undo
153 self.xUITest.executeCommand(".uno:Undo")
154 self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "")
156 # test cancel button
157 self.ui_test.execute_modeless_dialog_through_command(".uno:DescriptiveStatisticsDialog")
158 xDialog = self.xUITest.getTopFocusWindow()
159 xCancelBtn = xDialog.getChild("cancel")
160 self.ui_test.close_dialog_through_button(xCancelBtn)
162 self.ui_test.close_doc()
163 # vim: set shiftwidth=4 softtabstop=4 expandtab: