Move setting of LD_LIBRARY_PATH closer to invocation of cppunittester
[LibreOffice.git] / sc / qa / uitest / statistics / zTest.py
blob4ed285a9b8465fb5e69a530be19be63810a2e63f
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 zTest(UITestCase):
17 def test_zTest_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", "28")
23 enter_text_to_cell(gridwin, "A2", "26")
24 enter_text_to_cell(gridwin, "A3", "31")
25 enter_text_to_cell(gridwin, "A4", "23")
26 enter_text_to_cell(gridwin, "A5", "20")
27 enter_text_to_cell(gridwin, "A6", "27")
28 enter_text_to_cell(gridwin, "A7", "28")
29 enter_text_to_cell(gridwin, "A8", "14")
30 enter_text_to_cell(gridwin, "A9", "4")
31 enter_text_to_cell(gridwin, "A10", "0")
32 enter_text_to_cell(gridwin, "A11", "2")
33 enter_text_to_cell(gridwin, "A12", "8")
34 enter_text_to_cell(gridwin, "A13", "9")
36 enter_text_to_cell(gridwin, "B1", "19")
37 enter_text_to_cell(gridwin, "B2", "13")
38 enter_text_to_cell(gridwin, "B3", "12")
39 enter_text_to_cell(gridwin, "B4", "5")
40 enter_text_to_cell(gridwin, "B5", "34")
41 enter_text_to_cell(gridwin, "B6", "31")
42 enter_text_to_cell(gridwin, "B7", "31")
43 enter_text_to_cell(gridwin, "B8", "12")
44 enter_text_to_cell(gridwin, "B9", "24")
45 enter_text_to_cell(gridwin, "B10", "23")
46 enter_text_to_cell(gridwin, "B11", "19")
47 enter_text_to_cell(gridwin, "B12", "10")
48 enter_text_to_cell(gridwin, "B13", "33")
50 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"}))
51 with self.ui_test.execute_modeless_dialog_through_command(".uno:ZTestDialog") as xDialog:
52 xvariable1rangeedit = xDialog.getChild("variable1-range-edit")
53 xvariable2rangeedit = xDialog.getChild("variable2-range-edit")
54 xoutputrangeedit = xDialog.getChild("output-range-edit")
55 xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio")
57 xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
58 xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
59 xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$13"}))
60 xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
61 xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
62 xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$B$1:$B$13"}))
63 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
64 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
65 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"F1"}))
66 xgroupedbycolumnsradio.executeAction("CLICK", tuple())
67 #Verify
68 self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "z-test")
69 self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha")
71 self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Hypothesized Mean Difference")
72 self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Known Variance")
73 self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Mean")
74 self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "Observations")
75 self.assertEqual(get_cell_by_position(document, 0, 5, 7).getString(), "Observed Mean Difference")
76 self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "z")
77 self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "P (Z<=z) one-tail")
78 self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "z Critical one-tail")
79 self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "P (Z<=z) two-tail")
80 self.assertEqual(get_cell_by_position(document, 0, 5, 12).getString(), "z Critical two-tail")
82 self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0.05)
83 self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue(), 0)
84 self.assertEqual(get_cell_by_position(document, 0, 6, 3).getString(), "Variable 1")
85 self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue(), 0)
86 self.assertEqual(round(get_cell_by_position(document, 0, 6, 5).getValue(),12), 16.923076923077)
87 self.assertEqual(round(get_cell_by_position(document, 0, 6, 10).getValue(),12), 1.644853626951)
88 self.assertEqual(round(get_cell_by_position(document, 0, 6, 12).getValue(),12), 1.959963984540)
90 self.assertEqual(get_cell_by_position(document, 0, 7, 3).getString(), "Variable 2")
91 self.assertEqual(get_cell_by_position(document, 0, 7, 4).getValue(), 0)
92 self.assertEqual(round(get_cell_by_position(document, 0, 7, 5).getValue(),12), 20.461538461538)
93 self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue(), 13)
94 #undo
95 self.xUITest.executeCommand(".uno:Undo")
96 self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "")
98 # test cancel button
99 with self.ui_test.execute_modeless_dialog_through_command(".uno:ZTestDialog", close_button="cancel"):
100 pass
102 # vim: set shiftwidth=4 softtabstop=4 expandtab: