Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / qa / uitest / statistics / anova.py
blob50237ef928f992b93c8c06223f5ec2490efe95be
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 anova(UITestCase):
18 def test_statistic_anova(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", "Maths")
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")
37 enter_text_to_cell(gridwin, "B1", "Physics")
38 enter_text_to_cell(gridwin, "B2", "67")
39 enter_text_to_cell(gridwin, "B3", "68")
40 enter_text_to_cell(gridwin, "B4", "65")
41 enter_text_to_cell(gridwin, "B5", "64")
42 enter_text_to_cell(gridwin, "B6", "38")
43 enter_text_to_cell(gridwin, "B7", "84")
44 enter_text_to_cell(gridwin, "B8", "80")
45 enter_text_to_cell(gridwin, "B9", "49")
46 enter_text_to_cell(gridwin, "B10", "49")
47 enter_text_to_cell(gridwin, "B11", "33")
49 enter_text_to_cell(gridwin, "C1", "Biology")
50 enter_text_to_cell(gridwin, "C2", "33")
51 enter_text_to_cell(gridwin, "C3", "42")
52 enter_text_to_cell(gridwin, "C4", "44")
53 enter_text_to_cell(gridwin, "C5", "60")
54 enter_text_to_cell(gridwin, "C6", "43")
55 enter_text_to_cell(gridwin, "C7", "62")
56 enter_text_to_cell(gridwin, "C8", "51")
57 enter_text_to_cell(gridwin, "C9", "40")
58 enter_text_to_cell(gridwin, "C10", "12")
59 enter_text_to_cell(gridwin, "C11", "60")
60 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:C13"}))
61 self.ui_test.execute_modeless_dialog_through_command(".uno:AnalysisOfVarianceDialog")
62 xDialog = self.xUITest.getTopFocusWindow()
63 xinputrangeedit = xDialog.getChild("input-range-edit")
64 xoutputrangeedit = xDialog.getChild("output-range-edit")
65 xradiotwofactor = xDialog.getChild("radio-two-factor")
66 xradiosinglefactor = xDialog.getChild("radio-single-factor")
67 xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio")
68 xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio")
69 xalphaspin = xDialog.getChild("alpha-spin")
71 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
72 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
73 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$2:$C$13"}))
74 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
75 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
76 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"}))
77 xradiosinglefactor.executeAction("CLICK", tuple())
78 xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
79 xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
80 xalphaspin.executeAction("TYPE", mkPropertyValues({"TEXT":"0.05"}))
81 xOKBtn = xDialog.getChild("ok")
82 self.ui_test.close_dialog_through_button(xOKBtn)
83 #Verify
84 self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "ANOVA - Single Factor")
85 self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha")
86 self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Groups")
87 self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Column 1")
88 self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Column 2")
89 self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "Column 3")
90 self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "Source of Variation")
91 self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "Between Groups")
92 self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "Within Groups")
93 self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "Total")
95 self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0.05)
96 self.assertEqual(get_cell_by_position(document, 0, 6, 3).getString(), "Count")
97 self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue(), 11)
98 self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue(), 10)
99 self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 10)
100 self.assertEqual(get_cell_by_position(document, 0, 6, 8).getString(), "SS")
101 self.assertEqual(round(get_cell_by_position(document, 0, 6, 9).getValue(),11), 1876.56832844573)
102 self.assertEqual(round(get_cell_by_position(document, 0, 6, 10).getValue(),10), 6025.1090909091)
103 #bug 80583
104 self.assertEqual(round(get_cell_by_position(document, 0, 6, 11).getValue(),11), 7901.67741935484)
106 self.assertEqual(get_cell_by_position(document, 0, 7, 3).getString(), "Sum")
107 self.assertEqual(get_cell_by_position(document, 0, 7, 4).getValue(), 461)
108 self.assertEqual(get_cell_by_position(document, 0, 7, 5).getValue(), 597)
109 self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue(), 447)
110 self.assertEqual(get_cell_by_position(document, 0, 7, 8).getString(), "df")
111 self.assertEqual(get_cell_by_position(document, 0, 7, 9).getValue(), 2)
112 self.assertEqual(get_cell_by_position(document, 0, 7, 10).getValue(), 28)
113 self.assertEqual(get_cell_by_position(document, 0, 7, 11).getValue(), 30)
115 self.assertEqual(get_cell_by_position(document, 0, 8, 3).getString(), "Mean")
116 self.assertEqual(round(get_cell_by_position(document, 0, 8, 4).getValue(), 12), 41.909090909091)
117 self.assertEqual(get_cell_by_position(document, 0, 8, 5).getValue(), 59.7)
118 self.assertEqual(get_cell_by_position(document, 0, 8, 6).getValue(), 44.7)
119 self.assertEqual(get_cell_by_position(document, 0, 8, 8).getString(), "MS")
120 self.assertEqual(round(get_cell_by_position(document, 0, 8, 9).getValue(),11), 938.28416422287)
121 self.assertEqual(round(get_cell_by_position(document, 0, 8, 10).getValue(),11), 215.18246753247)
123 self.assertEqual(get_cell_by_position(document, 0, 9, 3).getString(), "Variance")
124 self.assertEqual(round(get_cell_by_position(document, 0, 9, 4).getValue(),11), 139.49090909091)
125 self.assertEqual(round(get_cell_by_position(document, 0, 9, 5).getValue(),12), 287.122222222222)
126 self.assertEqual(round(get_cell_by_position(document, 0, 9, 6).getValue(),12), 227.344444444444)
127 self.assertEqual(get_cell_by_position(document, 0, 9, 8).getString(), "F")
128 self.assertEqual(round(get_cell_by_position(document, 0, 9, 9).getValue(),13), 4.3604117704492)
130 self.assertEqual(get_cell_by_position(document, 0, 10, 8).getString(), "P-value")
131 self.assertEqual(round(get_cell_by_position(document, 0, 10, 9).getValue(),14), 0.02246149518799)
133 self.assertEqual(get_cell_by_position(document, 0, 11, 8).getString(), "F critical")
134 self.assertEqual(round(get_cell_by_position(document, 0, 11, 9).getValue(),13), 3.3403855582378)
136 #undo
137 self.xUITest.executeCommand(".uno:Undo")
138 self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "")
140 # test cancel button
141 self.ui_test.execute_modeless_dialog_through_command(".uno:AnalysisOfVarianceDialog")
142 xDialog = self.xUITest.getTopFocusWindow()
143 xCancelBtn = xDialog.getChild("cancel")
144 self.ui_test.close_dialog_through_button(xCancelBtn)
146 self.ui_test.close_doc()
147 # vim: set shiftwidth=4 softtabstop=4 expandtab: