Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / qa / uitest / statistics / tdf76731.py
blob0dc1f86cb7342dc0ed12aa848f6ab42c7640fc3c
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
16 import org.libreoffice.unotest
17 import pathlib
18 #Bug 76731 - ANOVA: F critical is not shown
20 def get_url_for_data_file(file_name):
21 return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
23 class anova(UITestCase):
24 def test_tdf76731_anova(self):
25 calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf76731.ods"))
26 xCalcDoc = self.xUITest.getTopFocusWindow()
27 gridwin = xCalcDoc.getChild("grid_window")
28 document = self.ui_test.get_component()
29 #1. Open the attached sample document in Calc.
30 #2. Select the data range, i.e. A1:C5.
31 gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C5"}))
32 #3. Choose Data - Analysis of Variance (ANOVA).
33 #4. Choose an arbitrary output cell and click OK.
34 self.ui_test.execute_modeless_dialog_through_command(".uno:AnalysisOfVarianceDialog")
35 xDialog = self.xUITest.getTopFocusWindow()
36 xinputrangeedit = xDialog.getChild("input-range-edit")
37 xoutputrangeedit = xDialog.getChild("output-range-edit")
38 xradiotwofactor = xDialog.getChild("radio-two-factor")
39 xradiosinglefactor = xDialog.getChild("radio-single-factor")
40 xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio")
41 xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio")
42 xalphaspin = xDialog.getChild("alpha-spin")
44 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
45 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
46 xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"}))
47 xradiosinglefactor.executeAction("CLICK", tuple())
48 xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
49 xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
50 xalphaspin.executeAction("TYPE", mkPropertyValues({"TEXT":"0.05"}))
51 xOKBtn = xDialog.getChild("ok")
52 self.ui_test.close_dialog_through_button(xOKBtn)
53 #Verify, Table of results is shown, "F critical" cell has "#NAME?" error value.
54 self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "ANOVA - Single Factor")
55 self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha")
56 self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Groups")
57 self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Column 1")
58 self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Column 2")
59 self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "Column 3")
60 self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "Source of Variation")
61 self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "Between Groups")
62 self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "Within Groups")
63 self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "Total")
65 self.assertEqual(get_cell_by_position(document, 0, 11, 8).getString(), "F critical")
66 self.assertEqual(round(get_cell_by_position(document, 0, 11, 9).getValue(),9), 3.885293835)
68 #undo
69 self.xUITest.executeCommand(".uno:Undo")
70 self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "")
72 self.ui_test.close_doc()
73 # vim: set shiftwidth=4 softtabstop=4 expandtab: