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 zTest(UITestCase
):
18 def test_zTest_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()
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:ZTestDialog")
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
)
74 self
.assertEqual(get_cell_by_position(document
, 0, 5, 0).getString(), "z-test")
75 self
.assertEqual(get_cell_by_position(document
, 0, 5, 1).getString(), "Alpha")
77 self
.assertEqual(get_cell_by_position(document
, 0, 5, 2).getString(), "Hypothesized Mean Difference")
78 self
.assertEqual(get_cell_by_position(document
, 0, 5, 4).getString(), "Known Variance")
79 self
.assertEqual(get_cell_by_position(document
, 0, 5, 5).getString(), "Mean")
80 self
.assertEqual(get_cell_by_position(document
, 0, 5, 6).getString(), "Observations")
81 self
.assertEqual(get_cell_by_position(document
, 0, 5, 7).getString(), "Observed Mean Difference")
82 self
.assertEqual(get_cell_by_position(document
, 0, 5, 8).getString(), "z")
83 self
.assertEqual(get_cell_by_position(document
, 0, 5, 9).getString(), "P (Z<=z) one-tail")
84 self
.assertEqual(get_cell_by_position(document
, 0, 5, 10).getString(), "z Critical one-tail")
85 self
.assertEqual(get_cell_by_position(document
, 0, 5, 11).getString(), "P (Z<=z) two-tail")
86 self
.assertEqual(get_cell_by_position(document
, 0, 5, 12).getString(), "z Critical two-tail")
88 self
.assertEqual(get_cell_by_position(document
, 0, 6, 1).getValue(), 0.05)
89 self
.assertEqual(get_cell_by_position(document
, 0, 6, 2).getValue(), 0)
90 self
.assertEqual(get_cell_by_position(document
, 0, 6, 3).getString(), "Variable 1")
91 self
.assertEqual(get_cell_by_position(document
, 0, 6, 4).getValue(), 0)
92 self
.assertEqual(round(get_cell_by_position(document
, 0, 6, 5).getValue(),12), 16.923076923077)
93 self
.assertEqual(round(get_cell_by_position(document
, 0, 6, 10).getValue(),12), 1.644853626951)
94 self
.assertEqual(round(get_cell_by_position(document
, 0, 6, 12).getValue(),12), 1.959963984540)
96 self
.assertEqual(get_cell_by_position(document
, 0, 7, 3).getString(), "Variable 2")
97 self
.assertEqual(get_cell_by_position(document
, 0, 7, 4).getValue(), 0)
98 self
.assertEqual(round(get_cell_by_position(document
, 0, 7, 5).getValue(),12), 20.461538461538)
99 self
.assertEqual(get_cell_by_position(document
, 0, 7, 6).getValue(), 13)
101 self
.xUITest
.executeCommand(".uno:Undo")
102 self
.assertEqual(get_cell_by_position(document
, 0, 5, 0).getString(), "")
105 self
.ui_test
.execute_modeless_dialog_through_command(".uno:ZTestDialog")
106 xDialog
= self
.xUITest
.getTopFocusWindow()
107 xCancelBtn
= xDialog
.getChild("cancel")
108 self
.ui_test
.close_dialog_through_button(xCancelBtn
)
110 self
.ui_test
.close_doc()
112 # vim: set shiftwidth=4 softtabstop=4 expandtab: