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 chiSquare(UITestCase
):
18 def test_chiSquare(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:ChiSquareTestDialog")
54 xDialog
= self
.xUITest
.getTopFocusWindow()
55 xinputrangeedit
= xDialog
.getChild("input-range-edit")
56 xoutputrangeedit
= xDialog
.getChild("output-range-edit")
57 xgroupedbyrowsradio
= xDialog
.getChild("groupedby-rows-radio")
58 xgroupedbycolumnsradio
= xDialog
.getChild("groupedby-columns-radio")
60 xinputrangeedit
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
61 xinputrangeedit
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
62 xinputrangeedit
.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$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 xOKBtn
= xDialog
.getChild("ok")
68 self
.ui_test
.close_dialog_through_button(xOKBtn
)
70 self
.assertEqual(get_cell_by_position(document
, 0, 5, 0).getString(), "Test of Independence (Chi-Square)")
71 self
.assertEqual(get_cell_by_position(document
, 0, 5, 1).getString(), "Alpha")
73 self
.assertEqual(get_cell_by_position(document
, 0, 5, 2).getString(), "df")
74 self
.assertEqual(get_cell_by_position(document
, 0, 5, 3).getString(), "P-value")
75 self
.assertEqual(get_cell_by_position(document
, 0, 5, 4).getString(), "Test Statistic")
76 self
.assertEqual(get_cell_by_position(document
, 0, 5, 5).getString(), "Critical Value")
78 self
.assertEqual(get_cell_by_position(document
, 0, 6, 1).getValue(), 0.05)
79 self
.assertEqual(get_cell_by_position(document
, 0, 6, 2).getValue(), 12)
80 self
.assertEqual(round(get_cell_by_position(document
, 0, 6, 4).getValue(),12), 91.687005584173)
81 self
.assertEqual(round(get_cell_by_position(document
, 0, 6, 5).getValue(),12), 21.026069817483)
84 self
.xUITest
.executeCommand(".uno:Undo")
85 self
.assertEqual(get_cell_by_position(document
, 0, 5, 0).getString(), "")
88 self
.ui_test
.execute_modeless_dialog_through_command(".uno:ChiSquareTestDialog")
89 xDialog
= self
.xUITest
.getTopFocusWindow()
90 xCancelBtn
= xDialog
.getChild("cancel")
91 self
.ui_test
.close_dialog_through_button(xCancelBtn
)
93 self
.ui_test
.close_doc()
95 # vim: set shiftwidth=4 softtabstop=4 expandtab: