Move setting of LD_LIBRARY_PATH closer to invocation of cppunittester
[LibreOffice.git] / sc / qa / uitest / statistics / anova.py
blob57e24b49b0da40c5ff81635c3f9acfb168dfd373
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 anova(UITestCase):
17 def test_statistic_anova(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": "A2:C13"}))
59 with self.ui_test.execute_modeless_dialog_through_command(".uno:AnalysisOfVarianceDialog") as xDialog:
60 xinputrangeedit = xDialog.getChild("input-range-edit")
61 xoutputrangeedit = xDialog.getChild("output-range-edit")
62 xradiosinglefactor = xDialog.getChild("radio-single-factor")
63 xalphaspin = xDialog.getChild("alpha-spin")
65 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
66 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
67 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$2:$C$13"}))
68 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
69 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
70 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"}))
71 xradiosinglefactor.executeAction("CLICK", tuple())
72 xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
73 xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
74 xalphaspin.executeAction("TYPE", mkPropertyValues({"TEXT":"0.05"}))
75 #Verify
76 self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "ANOVA - Single Factor")
77 self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha")
78 self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Groups")
79 self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Column 1")
80 self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Column 2")
81 self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "Column 3")
82 self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "Source of Variation")
83 self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "Between Groups")
84 self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "Within Groups")
85 self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "Total")
87 self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0.05)
88 self.assertEqual(get_cell_by_position(document, 0, 6, 3).getString(), "Count")
89 self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue(), 11)
90 self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue(), 10)
91 self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 10)
92 self.assertEqual(get_cell_by_position(document, 0, 6, 8).getString(), "SS")
93 self.assertEqual(round(get_cell_by_position(document, 0, 6, 9).getValue(),11), 1876.56832844575)
94 self.assertEqual(round(get_cell_by_position(document, 0, 6, 10).getValue(),10), 6025.1090909091)
95 #bug 80583
96 self.assertEqual(round(get_cell_by_position(document, 0, 6, 11).getValue(),11), 7901.67741935484)
98 self.assertEqual(get_cell_by_position(document, 0, 7, 3).getString(), "Sum")
99 self.assertEqual(get_cell_by_position(document, 0, 7, 4).getValue(), 461)
100 self.assertEqual(get_cell_by_position(document, 0, 7, 5).getValue(), 597)
101 self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue(), 447)
102 self.assertEqual(get_cell_by_position(document, 0, 7, 8).getString(), "df")
103 self.assertEqual(get_cell_by_position(document, 0, 7, 9).getValue(), 2)
104 self.assertEqual(get_cell_by_position(document, 0, 7, 10).getValue(), 28)
105 self.assertEqual(get_cell_by_position(document, 0, 7, 11).getValue(), 30)
107 self.assertEqual(get_cell_by_position(document, 0, 8, 3).getString(), "Mean")
108 self.assertEqual(round(get_cell_by_position(document, 0, 8, 4).getValue(), 12), 41.909090909091)
109 self.assertEqual(get_cell_by_position(document, 0, 8, 5).getValue(), 59.7)
110 self.assertEqual(get_cell_by_position(document, 0, 8, 6).getValue(), 44.7)
111 self.assertEqual(get_cell_by_position(document, 0, 8, 8).getString(), "MS")
112 self.assertEqual(round(get_cell_by_position(document, 0, 8, 9).getValue(),11), 938.28416422287)
113 self.assertEqual(round(get_cell_by_position(document, 0, 8, 10).getValue(),11), 215.18246753247)
115 self.assertEqual(get_cell_by_position(document, 0, 9, 3).getString(), "Variance")
116 self.assertEqual(round(get_cell_by_position(document, 0, 9, 4).getValue(),11), 139.49090909091)
117 self.assertEqual(round(get_cell_by_position(document, 0, 9, 5).getValue(),12), 287.122222222222)
118 self.assertEqual(round(get_cell_by_position(document, 0, 9, 6).getValue(),12), 227.344444444444)
119 self.assertEqual(get_cell_by_position(document, 0, 9, 8).getString(), "F")
120 self.assertEqual(round(get_cell_by_position(document, 0, 9, 9).getValue(),13), 4.3604117704492)
122 self.assertEqual(get_cell_by_position(document, 0, 10, 8).getString(), "P-value")
123 self.assertEqual(round(get_cell_by_position(document, 0, 10, 9).getValue(),14), 0.02246149518798)
125 self.assertEqual(get_cell_by_position(document, 0, 11, 8).getString(), "F critical")
126 self.assertEqual(round(get_cell_by_position(document, 0, 11, 9).getValue(),13), 3.3403855582378)
128 #undo
129 self.xUITest.executeCommand(".uno:Undo")
130 self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "")
132 # test cancel button
133 with self.ui_test.execute_modeless_dialog_through_command(".uno:AnalysisOfVarianceDialog", close_button="cancel"):
134 pass
136 # vim: set shiftwidth=4 softtabstop=4 expandtab: