Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / qa / uitest / statistics / sampling.py
blobdd3fd2698c5b4cee0e40bd484271c074bcf9ce5e
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 sampling(UITestCase):
18 def test_statistic_sampling(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", "11")
25 enter_text_to_cell(gridwin, "A2", "12")
26 enter_text_to_cell(gridwin, "A3", "13")
27 enter_text_to_cell(gridwin, "A4", "14")
28 enter_text_to_cell(gridwin, "A5", "15")
29 enter_text_to_cell(gridwin, "A6", "16")
30 enter_text_to_cell(gridwin, "A7", "17")
31 enter_text_to_cell(gridwin, "A8", "18")
32 enter_text_to_cell(gridwin, "A9", "19")
34 enter_text_to_cell(gridwin, "B1", "21")
35 enter_text_to_cell(gridwin, "B2", "22")
36 enter_text_to_cell(gridwin, "B3", "23")
37 enter_text_to_cell(gridwin, "B4", "24")
38 enter_text_to_cell(gridwin, "B5", "25")
39 enter_text_to_cell(gridwin, "B6", "26")
40 enter_text_to_cell(gridwin, "B7", "27")
41 enter_text_to_cell(gridwin, "B8", "28")
42 enter_text_to_cell(gridwin, "B9", "29")
44 enter_text_to_cell(gridwin, "C1", "31")
45 enter_text_to_cell(gridwin, "C2", "32")
46 enter_text_to_cell(gridwin, "C3", "33")
47 enter_text_to_cell(gridwin, "C4", "34")
48 enter_text_to_cell(gridwin, "C5", "35")
49 enter_text_to_cell(gridwin, "C6", "36")
50 enter_text_to_cell(gridwin, "C7", "37")
51 enter_text_to_cell(gridwin, "C8", "38")
52 enter_text_to_cell(gridwin, "C9", "39")
53 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C9"}))
54 self.ui_test.execute_modeless_dialog_through_command(".uno:SamplingDialog")
55 xDialog = self.xUITest.getTopFocusWindow()
56 xinputrangeedit = xDialog.getChild("input-range-edit")
57 xoutputrangeedit = xDialog.getChild("output-range-edit")
58 xrandommethodradio = xDialog.getChild("random-method-radio")
59 xsamplesizespin = xDialog.getChild("sample-size-spin")
60 xperiodicmethodradio = xDialog.getChild("periodic-method-radio")
61 xperiodspin = xDialog.getChild("period-spin")
63 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
64 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
65 xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$C$9"}))
67 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$F$1"}))
69 xperiodicmethodradio.executeAction("CLICK", tuple())
71 xperiodspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
72 xperiodspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
73 xperiodspin.executeAction("TYPE", mkPropertyValues({"TEXT":"2"}))
74 xOKBtn = xDialog.getChild("ok")
75 self.ui_test.close_dialog_through_button(xOKBtn)
76 #Verify
77 self.assertEqual(get_cell_by_position(document, 0, 5, 0).getValue(), 12)
78 self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue() , 14)
79 self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue() , 16)
80 self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue() , 18)
82 self.assertEqual(get_cell_by_position(document, 0, 6, 0).getValue(), 22)
83 self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue() , 24)
84 self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue() , 26)
85 self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue() , 28)
87 self.assertEqual(get_cell_by_position(document, 0, 7, 0).getValue(), 32)
88 self.assertEqual(get_cell_by_position(document, 0, 7, 1).getValue() , 34)
89 self.assertEqual(get_cell_by_position(document, 0, 7, 2).getValue() , 36)
90 self.assertEqual(get_cell_by_position(document, 0, 7, 3).getValue() , 38)
91 #undo
92 self.xUITest.executeCommand(".uno:Undo")
93 self.assertEqual(get_cell_by_position(document, 0, 5, 0).getValue(), 0)
94 self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue() , 0)
95 self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue() , 0)
96 self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue() , 0)
98 self.assertEqual(get_cell_by_position(document, 0, 6, 0).getValue(), 0)
99 self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue() , 0)
100 self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue() , 0)
101 self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue() , 0)
103 self.assertEqual(get_cell_by_position(document, 0, 7, 0).getValue(), 0)
104 self.assertEqual(get_cell_by_position(document, 0, 7, 1).getValue() , 0)
105 self.assertEqual(get_cell_by_position(document, 0, 7, 2).getValue() , 0)
106 self.assertEqual(get_cell_by_position(document, 0, 7, 3).getValue() , 0)
108 # test cancel button
109 self.ui_test.execute_modeless_dialog_through_command(".uno:SamplingDialog")
110 xDialog = self.xUITest.getTopFocusWindow()
111 xCancelBtn = xDialog.getChild("cancel")
112 self.ui_test.close_dialog_through_button(xCancelBtn)
114 self.ui_test.close_doc()
115 # vim: set shiftwidth=4 softtabstop=4 expandtab: