Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / qa / uitest / statistics / tTest.py
blob035bb4ef6d893561d6bde0f772da8c7c729476f3
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 tTest(UITestCase):
18 def test_tTest_column(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", "28")
25 enter_text_to_cell(gridwin, "A2", "26")
26 enter_text_to_cell(gridwin, "A3", "31")
27 enter_text_to_cell(gridwin, "A4", "23")
28 enter_text_to_cell(gridwin, "A5", "20")
29 enter_text_to_cell(gridwin, "A6", "27")
30 enter_text_to_cell(gridwin, "A7", "28")
31 enter_text_to_cell(gridwin, "A8", "14")
32 enter_text_to_cell(gridwin, "A9", "4")
33 enter_text_to_cell(gridwin, "A10", "0")
34 enter_text_to_cell(gridwin, "A11", "2")
35 enter_text_to_cell(gridwin, "A12", "8")
36 enter_text_to_cell(gridwin, "A13", "9")
38 enter_text_to_cell(gridwin, "B1", "19")
39 enter_text_to_cell(gridwin, "B2", "13")
40 enter_text_to_cell(gridwin, "B3", "12")
41 enter_text_to_cell(gridwin, "B4", "5")
42 enter_text_to_cell(gridwin, "B5", "34")
43 enter_text_to_cell(gridwin, "B6", "31")
44 enter_text_to_cell(gridwin, "B7", "31")
45 enter_text_to_cell(gridwin, "B8", "12")
46 enter_text_to_cell(gridwin, "B9", "24")
47 enter_text_to_cell(gridwin, "B10", "23")
48 enter_text_to_cell(gridwin, "B11", "19")
49 enter_text_to_cell(gridwin, "B12", "10")
50 enter_text_to_cell(gridwin, "B13", "33")
52 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"}))
53 self.ui_test.execute_modeless_dialog_through_command(".uno:TTestDialog")
54 xDialog = self.xUITest.getTopFocusWindow()
55 xvariable1rangeedit = xDialog.getChild("variable1-range-edit")
56 xvariable2rangeedit = xDialog.getChild("variable2-range-edit")
57 xoutputrangeedit = xDialog.getChild("output-range-edit")
58 xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio")
59 xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio")
61 xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
62 xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
63 xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$13"}))
64 xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
65 xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
66 xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$B$1:$B$13"}))
67 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
68 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
69 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"F1"}))
70 xgroupedbycolumnsradio.executeAction("CLICK", tuple())
71 xOKBtn = xDialog.getChild("ok")
72 self.ui_test.close_dialog_through_button(xOKBtn)
73 #Verify
74 self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Paired t-test")
75 self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha")
76 self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Hypothesized Mean Difference")
77 self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Mean")
78 self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Variance")
79 self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "Observations")
80 self.assertEqual(get_cell_by_position(document, 0, 5, 7).getString(), "Pearson Correlation")
81 self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "Observed Mean Difference")
82 self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "Variance of the Differences")
83 self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "df")
84 self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "t Stat")
85 self.assertEqual(get_cell_by_position(document, 0, 5, 12).getString(), "P (T<=t) one-tail")
86 self.assertEqual(get_cell_by_position(document, 0, 5, 13).getString(), "t Critical one-tail")
87 self.assertEqual(get_cell_by_position(document, 0, 5, 14).getString(), "P (T<=t) two-tail")
88 self.assertEqual(get_cell_by_position(document, 0, 5, 15).getString(), "t Critical two-tail")
90 self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0.05)
91 self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue(), 0)
92 self.assertEqual(get_cell_by_position(document, 0, 6, 3).getString(), "Variable 1")
93 self.assertEqual(round(get_cell_by_position(document, 0, 6, 4).getValue(),12), 16.923076923077)
94 self.assertEqual(round(get_cell_by_position(document, 0, 6, 5).getValue(),12), 125.076923076923)
95 self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 13)
96 self.assertEqual(round(get_cell_by_position(document, 0, 6, 7).getValue(),12), -0.061753977175)
97 self.assertEqual(round(get_cell_by_position(document, 0, 6, 8).getValue(),12), -3.538461538462)
98 self.assertEqual(round(get_cell_by_position(document, 0, 6, 9).getValue(),12), 232.935897435897)
99 self.assertEqual(get_cell_by_position(document, 0, 6, 10).getValue(), 12)
100 self.assertEqual(round(get_cell_by_position(document, 0, 6, 11).getValue(),12), -0.835926213674)
101 self.assertEqual(round(get_cell_by_position(document, 0, 6, 12).getValue(),12), 0.209765144211)
102 self.assertEqual(round(get_cell_by_position(document, 0, 6, 13).getValue(),12), 1.782287555649)
103 self.assertEqual(round(get_cell_by_position(document, 0, 6, 14).getValue(),12), 0.419530288422)
104 self.assertEqual(round(get_cell_by_position(document, 0, 6, 15).getValue(),12), 2.178812829667)
106 self.assertEqual(get_cell_by_position(document, 0, 7, 3).getString(), "Variable 2")
107 self.assertEqual(round(get_cell_by_position(document, 0, 7, 4).getValue(),12), 20.461538461538)
108 self.assertEqual(round(get_cell_by_position(document, 0, 7, 5).getValue(),12), 94.435897435897)
109 self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue(), 13)
110 #undo
111 self.xUITest.executeCommand(".uno:Undo")
112 self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "")
114 # test cancel button
115 self.ui_test.execute_modeless_dialog_through_command(".uno:TTestDialog")
116 xDialog = self.xUITest.getTopFocusWindow()
117 xCancelBtn = xDialog.getChild("cancel")
118 self.ui_test.close_dialog_through_button(xCancelBtn)
120 self.ui_test.close_doc()
122 # vim: set shiftwidth=4 softtabstop=4 expandtab: