1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
from uitest.framework import UITestCase
from uitest.uihelper.common import get_state_as_dict
from uitest.uihelper.common import select_pos
from uitest.uihelper.calc import enter_text_to_cell
from libreoffice.calc.document import get_sheet_from_doc
from libreoffice.calc.conditional_format import get_conditional_format_from_sheet
from uitest.debug import sleep
from libreoffice.calc.document import get_cell_by_position
from libreoffice.uno.propertyvalue import mkPropertyValues
class zTest(UITestCase):
def test_zTest_column(self):
calc_doc = self.ui_test.create_doc_in_start_center("calc")
xCalcDoc = self.xUITest.getTopFocusWindow()
gridwin = xCalcDoc.getChild("grid_window")
document = self.ui_test.get_component()
#fill data
enter_text_to_cell(gridwin, "A1", "28")
enter_text_to_cell(gridwin, "A2", "26")
enter_text_to_cell(gridwin, "A3", "31")
enter_text_to_cell(gridwin, "A4", "23")
enter_text_to_cell(gridwin, "A5", "20")
enter_text_to_cell(gridwin, "A6", "27")
enter_text_to_cell(gridwin, "A7", "28")
enter_text_to_cell(gridwin, "A8", "14")
enter_text_to_cell(gridwin, "A9", "4")
enter_text_to_cell(gridwin, "A10", "0")
enter_text_to_cell(gridwin, "A11", "2")
enter_text_to_cell(gridwin, "A12", "8")
enter_text_to_cell(gridwin, "A13", "9")
enter_text_to_cell(gridwin, "B1", "19")
enter_text_to_cell(gridwin, "B2", "13")
enter_text_to_cell(gridwin, "B3", "12")
enter_text_to_cell(gridwin, "B4", "5")
enter_text_to_cell(gridwin, "B5", "34")
enter_text_to_cell(gridwin, "B6", "31")
enter_text_to_cell(gridwin, "B7", "31")
enter_text_to_cell(gridwin, "B8", "12")
enter_text_to_cell(gridwin, "B9", "24")
enter_text_to_cell(gridwin, "B10", "23")
enter_text_to_cell(gridwin, "B11", "19")
enter_text_to_cell(gridwin, "B12", "10")
enter_text_to_cell(gridwin, "B13", "33")
gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"}))
self.ui_test.execute_modeless_dialog_through_command(".uno:ZTestDialog")
xDialog = self.xUITest.getTopFocusWindow()
xvariable1rangeedit = xDialog.getChild("variable1-range-edit")
xvariable2rangeedit = xDialog.getChild("variable2-range-edit")
xoutputrangeedit = xDialog.getChild("output-range-edit")
xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio")
xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio")
xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$13"}))
xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$B$1:$B$13"}))
xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"F1"}))
xgroupedbycolumnsradio.executeAction("CLICK", tuple())
xOKBtn = xDialog.getChild("ok")
self.ui_test.close_dialog_through_button(xOKBtn)
#Verify
self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "z-test")
self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha")
self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Hypothesized Mean Difference")
self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Known Variance")
self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Mean")
self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "Observations")
self.assertEqual(get_cell_by_position(document, 0, 5, 7).getString(), "Observed Mean Difference")
self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "z")
self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "P (Z<=z) one-tail")
self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "z Critical one-tail")
self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "P (Z<=z) two-tail")
self.assertEqual(get_cell_by_position(document, 0, 5, 12).getString(), "z Critical two-tail")
self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0.05)
self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue(), 0)
self.assertEqual(get_cell_by_position(document, 0, 6, 3).getString(), "Variable 1")
self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue(), 0)
self.assertEqual(round(get_cell_by_position(document, 0, 6, 5).getValue(),12), 16.923076923077)
self.assertEqual(round(get_cell_by_position(document, 0, 6, 10).getValue(),12), 1.644853626951)
self.assertEqual(round(get_cell_by_position(document, 0, 6, 12).getValue(),12), 1.959963984540)
self.assertEqual(get_cell_by_position(document, 0, 7, 3).getString(), "Variable 2")
self.assertEqual(get_cell_by_position(document, 0, 7, 4).getValue(), 0)
self.assertEqual(round(get_cell_by_position(document, 0, 7, 5).getValue(),12), 20.461538461538)
self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue(), 13)
#undo
self.xUITest.executeCommand(".uno:Undo")
self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "")
# test cancel button
self.ui_test.execute_modeless_dialog_through_command(".uno:ZTestDialog")
xDialog = self.xUITest.getTopFocusWindow()
xCancelBtn = xDialog.getChild("cancel")
self.ui_test.close_dialog_through_button(xCancelBtn)
self.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab:
|