diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /sc/qa/uitest/statistics | |
parent | Initial commit. (diff) | |
download | libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sc/qa/uitest/statistics')
-rw-r--r-- | sc/qa/uitest/statistics/anova.py | 136 | ||||
-rw-r--r-- | sc/qa/uitest/statistics/chiSquare.py | 85 | ||||
-rw-r--r-- | sc/qa/uitest/statistics/correlation.py | 187 | ||||
-rw-r--r-- | sc/qa/uitest/statistics/covariance.py | 184 | ||||
-rw-r--r-- | sc/qa/uitest/statistics/descriptiveStatistics.py | 155 | ||||
-rw-r--r-- | sc/qa/uitest/statistics/exponentialSmoothing.py | 173 | ||||
-rw-r--r-- | sc/qa/uitest/statistics/fTest.py | 111 | ||||
-rw-r--r-- | sc/qa/uitest/statistics/movingAverage.py | 166 | ||||
-rw-r--r-- | sc/qa/uitest/statistics/regression.py | 104 | ||||
-rw-r--r-- | sc/qa/uitest/statistics/sampling.py | 147 | ||||
-rw-r--r-- | sc/qa/uitest/statistics/tTest.py | 112 | ||||
-rw-r--r-- | sc/qa/uitest/statistics/tdf76731.py | 58 | ||||
-rw-r--r-- | sc/qa/uitest/statistics/zTest.py | 102 |
13 files changed, 1720 insertions, 0 deletions
diff --git a/sc/qa/uitest/statistics/anova.py b/sc/qa/uitest/statistics/anova.py new file mode 100644 index 000000000..57e24b49b --- /dev/null +++ b/sc/qa/uitest/statistics/anova.py @@ -0,0 +1,136 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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.calc import enter_text_to_cell + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class anova(UITestCase): + def test_statistic_anova(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "Maths") + enter_text_to_cell(gridwin, "A2", "47") + enter_text_to_cell(gridwin, "A3", "36") + enter_text_to_cell(gridwin, "A4", "40") + enter_text_to_cell(gridwin, "A5", "39") + enter_text_to_cell(gridwin, "A7", "47") + enter_text_to_cell(gridwin, "A8", "29") + enter_text_to_cell(gridwin, "A9", "27") + enter_text_to_cell(gridwin, "A10", "57") + enter_text_to_cell(gridwin, "A11", "56") + enter_text_to_cell(gridwin, "A12", "57") + enter_text_to_cell(gridwin, "A13", "26") + + enter_text_to_cell(gridwin, "B1", "Physics") + enter_text_to_cell(gridwin, "B2", "67") + enter_text_to_cell(gridwin, "B3", "68") + enter_text_to_cell(gridwin, "B4", "65") + enter_text_to_cell(gridwin, "B5", "64") + enter_text_to_cell(gridwin, "B6", "38") + enter_text_to_cell(gridwin, "B7", "84") + enter_text_to_cell(gridwin, "B8", "80") + enter_text_to_cell(gridwin, "B9", "49") + enter_text_to_cell(gridwin, "B10", "49") + enter_text_to_cell(gridwin, "B11", "33") + + enter_text_to_cell(gridwin, "C1", "Biology") + enter_text_to_cell(gridwin, "C2", "33") + enter_text_to_cell(gridwin, "C3", "42") + enter_text_to_cell(gridwin, "C4", "44") + enter_text_to_cell(gridwin, "C5", "60") + enter_text_to_cell(gridwin, "C6", "43") + enter_text_to_cell(gridwin, "C7", "62") + enter_text_to_cell(gridwin, "C8", "51") + enter_text_to_cell(gridwin, "C9", "40") + enter_text_to_cell(gridwin, "C10", "12") + enter_text_to_cell(gridwin, "C11", "60") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:C13"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:AnalysisOfVarianceDialog") as xDialog: + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xradiosinglefactor = xDialog.getChild("radio-single-factor") + xalphaspin = xDialog.getChild("alpha-spin") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$2:$C$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) + xradiosinglefactor.executeAction("CLICK", tuple()) + xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xalphaspin.executeAction("TYPE", mkPropertyValues({"TEXT":"0.05"})) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "ANOVA - Single Factor") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha") + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Groups") + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Column 1") + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Column 2") + self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "Column 3") + self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "Source of Variation") + self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "Between Groups") + self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "Within Groups") + self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "Total") + + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0.05) + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getString(), "Count") + self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue(), 11) + self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue(), 10) + self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 10) + self.assertEqual(get_cell_by_position(document, 0, 6, 8).getString(), "SS") + self.assertEqual(round(get_cell_by_position(document, 0, 6, 9).getValue(),11), 1876.56832844575) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 10).getValue(),10), 6025.1090909091) + #bug 80583 + self.assertEqual(round(get_cell_by_position(document, 0, 6, 11).getValue(),11), 7901.67741935484) + + self.assertEqual(get_cell_by_position(document, 0, 7, 3).getString(), "Sum") + self.assertEqual(get_cell_by_position(document, 0, 7, 4).getValue(), 461) + self.assertEqual(get_cell_by_position(document, 0, 7, 5).getValue(), 597) + self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue(), 447) + self.assertEqual(get_cell_by_position(document, 0, 7, 8).getString(), "df") + self.assertEqual(get_cell_by_position(document, 0, 7, 9).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 7, 10).getValue(), 28) + self.assertEqual(get_cell_by_position(document, 0, 7, 11).getValue(), 30) + + self.assertEqual(get_cell_by_position(document, 0, 8, 3).getString(), "Mean") + self.assertEqual(round(get_cell_by_position(document, 0, 8, 4).getValue(), 12), 41.909090909091) + self.assertEqual(get_cell_by_position(document, 0, 8, 5).getValue(), 59.7) + self.assertEqual(get_cell_by_position(document, 0, 8, 6).getValue(), 44.7) + self.assertEqual(get_cell_by_position(document, 0, 8, 8).getString(), "MS") + self.assertEqual(round(get_cell_by_position(document, 0, 8, 9).getValue(),11), 938.28416422287) + self.assertEqual(round(get_cell_by_position(document, 0, 8, 10).getValue(),11), 215.18246753247) + + self.assertEqual(get_cell_by_position(document, 0, 9, 3).getString(), "Variance") + self.assertEqual(round(get_cell_by_position(document, 0, 9, 4).getValue(),11), 139.49090909091) + self.assertEqual(round(get_cell_by_position(document, 0, 9, 5).getValue(),12), 287.122222222222) + self.assertEqual(round(get_cell_by_position(document, 0, 9, 6).getValue(),12), 227.344444444444) + self.assertEqual(get_cell_by_position(document, 0, 9, 8).getString(), "F") + self.assertEqual(round(get_cell_by_position(document, 0, 9, 9).getValue(),13), 4.3604117704492) + + self.assertEqual(get_cell_by_position(document, 0, 10, 8).getString(), "P-value") + self.assertEqual(round(get_cell_by_position(document, 0, 10, 9).getValue(),14), 0.02246149518798) + + self.assertEqual(get_cell_by_position(document, 0, 11, 8).getString(), "F critical") + self.assertEqual(round(get_cell_by_position(document, 0, 11, 9).getValue(),13), 3.3403855582378) + + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + + # test cancel button + with self.ui_test.execute_modeless_dialog_through_command(".uno:AnalysisOfVarianceDialog", close_button="cancel"): + pass + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/chiSquare.py b/sc/qa/uitest/statistics/chiSquare.py new file mode 100644 index 000000000..1bc2e7f3a --- /dev/null +++ b/sc/qa/uitest/statistics/chiSquare.py @@ -0,0 +1,85 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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.calc import enter_text_to_cell + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class chiSquare(UITestCase): + def test_chiSquare(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #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"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:ChiSquareTestDialog") as xDialog: + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$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()) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Test of Independence (Chi-Square)") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha") + + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "df") + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "P-value") + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Test Statistic") + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Critical Value") + + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0.05) + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue(), 12) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 4).getValue(),12), 91.687005584173) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 5).getValue(),12), 21.026069817483) + + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + + # test cancel button + with self.ui_test.execute_modeless_dialog_through_command(".uno:ChiSquareTestDialog", close_button="cancel"): + pass + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/correlation.py b/sc/qa/uitest/statistics/correlation.py new file mode 100644 index 000000000..a7f67a2e7 --- /dev/null +++ b/sc/qa/uitest/statistics/correlation.py @@ -0,0 +1,187 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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.calc import enter_text_to_cell + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class correlation(UITestCase): + def test_statistic_correlation_column(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "Maths") + enter_text_to_cell(gridwin, "A2", "47") + enter_text_to_cell(gridwin, "A3", "36") + enter_text_to_cell(gridwin, "A4", "40") + enter_text_to_cell(gridwin, "A5", "39") + enter_text_to_cell(gridwin, "A7", "47") + enter_text_to_cell(gridwin, "A8", "29") + enter_text_to_cell(gridwin, "A9", "27") + enter_text_to_cell(gridwin, "A10", "57") + enter_text_to_cell(gridwin, "A11", "56") + enter_text_to_cell(gridwin, "A12", "57") + enter_text_to_cell(gridwin, "A13", "26") + + enter_text_to_cell(gridwin, "B1", "Physics") + enter_text_to_cell(gridwin, "B2", "67") + enter_text_to_cell(gridwin, "B3", "68") + enter_text_to_cell(gridwin, "B4", "65") + enter_text_to_cell(gridwin, "B5", "64") + enter_text_to_cell(gridwin, "B6", "38") + enter_text_to_cell(gridwin, "B7", "84") + enter_text_to_cell(gridwin, "B8", "80") + enter_text_to_cell(gridwin, "B9", "49") + enter_text_to_cell(gridwin, "B10", "49") + enter_text_to_cell(gridwin, "B11", "33") + + enter_text_to_cell(gridwin, "C1", "Biology") + enter_text_to_cell(gridwin, "C2", "33") + enter_text_to_cell(gridwin, "C3", "42") + enter_text_to_cell(gridwin, "C4", "44") + enter_text_to_cell(gridwin, "C5", "60") + enter_text_to_cell(gridwin, "C6", "43") + enter_text_to_cell(gridwin, "C7", "62") + enter_text_to_cell(gridwin, "C8", "51") + enter_text_to_cell(gridwin, "C9", "40") + enter_text_to_cell(gridwin, "C10", "12") + enter_text_to_cell(gridwin, "C11", "60") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C13"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:CorrelationDialog") as xDialog: + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$C$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) + xgroupedbyrowsradio.executeAction("CLICK", tuple()) + xgroupedbycolumnsradio.executeAction("CLICK", tuple()) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Correlations") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Column 1") + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Column 2") + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Column 3") + + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "Column 1") + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 1) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 2).getValue(),14), -0.40292549168204) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 3).getValue(),14), -0.21076428363645) + + self.assertEqual(get_cell_by_position(document, 0, 7, 0).getString(), "Column 2") + self.assertEqual(get_cell_by_position(document, 0, 7, 2).getValue(), 1) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 3).getValue(),14), 0.23097140475091) + + self.assertEqual(get_cell_by_position(document, 0, 8, 0).getString(), "Column 3") + self.assertEqual(get_cell_by_position(document, 0, 8, 3).getValue(), 1) + + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + + # test cancel button + with self.ui_test.execute_modeless_dialog_through_command(".uno:CorrelationDialog", close_button="cancel"): + pass + + def test_statistic_correlation_row(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "Maths") + enter_text_to_cell(gridwin, "A2", "Physics") + enter_text_to_cell(gridwin, "A3", "Biology") + + enter_text_to_cell(gridwin, "B1", "47") + enter_text_to_cell(gridwin, "B2", "67") + enter_text_to_cell(gridwin, "B3", "33") + + enter_text_to_cell(gridwin, "C1", "36") + enter_text_to_cell(gridwin, "C2", "68") + enter_text_to_cell(gridwin, "C3", "42") + + enter_text_to_cell(gridwin, "D1", "40") + enter_text_to_cell(gridwin, "D2", "65") + enter_text_to_cell(gridwin, "D3", "44") + + enter_text_to_cell(gridwin, "E1", "39") + enter_text_to_cell(gridwin, "E2", "64") + enter_text_to_cell(gridwin, "E3", "60") + + enter_text_to_cell(gridwin, "F2", "38") + enter_text_to_cell(gridwin, "F3", "43") + + enter_text_to_cell(gridwin, "G1", "47") + enter_text_to_cell(gridwin, "G2", "84") + enter_text_to_cell(gridwin, "G3", "62") + + enter_text_to_cell(gridwin, "H1", "29") + enter_text_to_cell(gridwin, "H2", "80") + enter_text_to_cell(gridwin, "H3", "51") + + enter_text_to_cell(gridwin, "I1", "27") + enter_text_to_cell(gridwin, "I2", "49") + enter_text_to_cell(gridwin, "I3", "40") + + enter_text_to_cell(gridwin, "J1", "57") + enter_text_to_cell(gridwin, "J2", "49") + enter_text_to_cell(gridwin, "J3", "12") + + enter_text_to_cell(gridwin, "K1", "56") + enter_text_to_cell(gridwin, "K2", "33") + enter_text_to_cell(gridwin, "K3", "60") + + enter_text_to_cell(gridwin, "L1", "57") + + enter_text_to_cell(gridwin, "M1", "26") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:M3"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:CorrelationDialog") as xDialog: + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$M$3"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$A$7"})) + xgroupedbyrowsradio.executeAction("CLICK", tuple()) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 6).getString(), "Correlations") + self.assertEqual(get_cell_by_position(document, 0, 0, 7).getString(), "Row 1") + self.assertEqual(get_cell_by_position(document, 0, 0, 8).getString(), "Row 2") + self.assertEqual(get_cell_by_position(document, 0, 0, 9).getString(), "Row 3") + + self.assertEqual(get_cell_by_position(document, 0, 1, 6).getString(), "Row 1") + self.assertEqual(get_cell_by_position(document, 0, 1, 7).getValue(), 1) + self.assertEqual(round(get_cell_by_position(document, 0, 1, 8).getValue(),15), -0.402925491682042) + self.assertEqual(round(get_cell_by_position(document, 0, 1, 9).getValue(),15), -0.210764283636454) + + self.assertEqual(get_cell_by_position(document, 0, 2, 6).getString(), "Row 2") + self.assertEqual(get_cell_by_position(document, 0, 2, 8).getValue(), 1) + self.assertEqual(round(get_cell_by_position(document, 0, 2, 9).getValue(),14), 0.23097140475091) + + self.assertEqual(get_cell_by_position(document, 0, 3, 6).getString(), "Row 3") + self.assertEqual(get_cell_by_position(document, 0, 3, 9).getValue(), 1) + + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/covariance.py b/sc/qa/uitest/statistics/covariance.py new file mode 100644 index 000000000..cec5a1d78 --- /dev/null +++ b/sc/qa/uitest/statistics/covariance.py @@ -0,0 +1,184 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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.calc import enter_text_to_cell + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class covariance(UITestCase): + def test_statistic_covariance_column(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "Maths") + enter_text_to_cell(gridwin, "A2", "47") + enter_text_to_cell(gridwin, "A3", "36") + enter_text_to_cell(gridwin, "A4", "40") + enter_text_to_cell(gridwin, "A5", "39") + enter_text_to_cell(gridwin, "A7", "47") + enter_text_to_cell(gridwin, "A8", "29") + enter_text_to_cell(gridwin, "A9", "27") + enter_text_to_cell(gridwin, "A10", "57") + enter_text_to_cell(gridwin, "A11", "56") + enter_text_to_cell(gridwin, "A12", "57") + enter_text_to_cell(gridwin, "A13", "26") + + enter_text_to_cell(gridwin, "B1", "Physics") + enter_text_to_cell(gridwin, "B2", "67") + enter_text_to_cell(gridwin, "B3", "68") + enter_text_to_cell(gridwin, "B4", "65") + enter_text_to_cell(gridwin, "B5", "64") + enter_text_to_cell(gridwin, "B6", "38") + enter_text_to_cell(gridwin, "B7", "84") + enter_text_to_cell(gridwin, "B8", "80") + enter_text_to_cell(gridwin, "B9", "49") + enter_text_to_cell(gridwin, "B10", "49") + enter_text_to_cell(gridwin, "B11", "33") + + enter_text_to_cell(gridwin, "C1", "Biology") + enter_text_to_cell(gridwin, "C2", "33") + enter_text_to_cell(gridwin, "C3", "42") + enter_text_to_cell(gridwin, "C4", "44") + enter_text_to_cell(gridwin, "C5", "60") + enter_text_to_cell(gridwin, "C6", "43") + enter_text_to_cell(gridwin, "C7", "62") + enter_text_to_cell(gridwin, "C8", "51") + enter_text_to_cell(gridwin, "C9", "40") + enter_text_to_cell(gridwin, "C10", "12") + enter_text_to_cell(gridwin, "C11", "60") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C13"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:CovarianceDialog") as xDialog: + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$C$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) + xgroupedbycolumnsradio.executeAction("CLICK", tuple()) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Covariances") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Column 1") + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Column 2") + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Column 3") + + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "Column 1") + self.assertEqual(round(get_cell_by_position(document, 0, 6, 1).getValue(),11), 126.80991735537) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 2).getValue(),12), -61.444444444444) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 3).getValue()), -32) + + self.assertEqual(get_cell_by_position(document, 0, 7, 0).getString(), "Column 2") + self.assertEqual(round(get_cell_by_position(document, 0, 7, 2).getValue(),2), 258.41) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 3).getValue(),2), 53.11) + + self.assertEqual(get_cell_by_position(document, 0, 8, 0).getString(), "Column 3") + self.assertEqual(round(get_cell_by_position(document, 0, 8, 3).getValue(),2), 204.61) + + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + + # test cancel button + with self.ui_test.execute_modeless_dialog_through_command(".uno:CovarianceDialog", close_button="cancel"): + pass + + def test_statistic_covariance_row(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "Maths") + enter_text_to_cell(gridwin, "A2", "Physics") + enter_text_to_cell(gridwin, "A3", "Biology") + + enter_text_to_cell(gridwin, "B1", "47") + enter_text_to_cell(gridwin, "B2", "67") + enter_text_to_cell(gridwin, "B3", "33") + + enter_text_to_cell(gridwin, "C1", "36") + enter_text_to_cell(gridwin, "C2", "68") + enter_text_to_cell(gridwin, "C3", "42") + + enter_text_to_cell(gridwin, "D1", "40") + enter_text_to_cell(gridwin, "D2", "65") + enter_text_to_cell(gridwin, "D3", "44") + + enter_text_to_cell(gridwin, "E1", "39") + enter_text_to_cell(gridwin, "E2", "64") + enter_text_to_cell(gridwin, "E3", "60") + + enter_text_to_cell(gridwin, "F2", "38") + enter_text_to_cell(gridwin, "F3", "43") + + enter_text_to_cell(gridwin, "G1", "47") + enter_text_to_cell(gridwin, "G2", "84") + enter_text_to_cell(gridwin, "G3", "62") + + enter_text_to_cell(gridwin, "H1", "29") + enter_text_to_cell(gridwin, "H2", "80") + enter_text_to_cell(gridwin, "H3", "51") + + enter_text_to_cell(gridwin, "I1", "27") + enter_text_to_cell(gridwin, "I2", "49") + enter_text_to_cell(gridwin, "I3", "40") + + enter_text_to_cell(gridwin, "J1", "57") + enter_text_to_cell(gridwin, "J2", "49") + enter_text_to_cell(gridwin, "J3", "12") + + enter_text_to_cell(gridwin, "K1", "56") + enter_text_to_cell(gridwin, "K2", "33") + enter_text_to_cell(gridwin, "K3", "60") + + enter_text_to_cell(gridwin, "L1", "57") + + enter_text_to_cell(gridwin, "M1", "26") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:M3"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:CovarianceDialog") as xDialog: + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$M$3"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$A$7"})) + xgroupedbyrowsradio.executeAction("CLICK", tuple()) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 6).getString(), "Covariances") + self.assertEqual(get_cell_by_position(document, 0, 0, 7).getString(), "Row 1") + self.assertEqual(get_cell_by_position(document, 0, 0, 8).getString(), "Row 2") + self.assertEqual(get_cell_by_position(document, 0, 0, 9).getString(), "Row 3") + + self.assertEqual(get_cell_by_position(document, 0, 1, 6).getString(), "Row 1") + self.assertEqual(round(get_cell_by_position(document, 0, 1, 7).getValue(),10), 126.8099173554) + self.assertEqual(round(get_cell_by_position(document, 0, 1, 8).getValue(),12), -61.444444444444) + self.assertEqual(round(get_cell_by_position(document, 0, 1, 9).getValue()), -32) + + self.assertEqual(get_cell_by_position(document, 0, 2, 6).getString(), "Row 2") + self.assertEqual(round(get_cell_by_position(document, 0, 2, 8).getValue(),2), 258.41) + self.assertEqual(round(get_cell_by_position(document, 0, 2, 9).getValue(),2), 53.11) + + self.assertEqual(get_cell_by_position(document, 0, 3, 6).getString(), "Row 3") + self.assertEqual(round(get_cell_by_position(document, 0, 3, 9).getValue(),2), 204.61) + + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/descriptiveStatistics.py b/sc/qa/uitest/statistics/descriptiveStatistics.py new file mode 100644 index 000000000..48a15e641 --- /dev/null +++ b/sc/qa/uitest/statistics/descriptiveStatistics.py @@ -0,0 +1,155 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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.calc import enter_text_to_cell + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class descriptiveStatistics(UITestCase): + def test_descriptive_statistics(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "Math") + enter_text_to_cell(gridwin, "A2", "47") + enter_text_to_cell(gridwin, "A3", "36") + enter_text_to_cell(gridwin, "A4", "40") + enter_text_to_cell(gridwin, "A5", "39") + enter_text_to_cell(gridwin, "A7", "47") + enter_text_to_cell(gridwin, "A8", "29") + enter_text_to_cell(gridwin, "A9", "27") + enter_text_to_cell(gridwin, "A10", "57") + enter_text_to_cell(gridwin, "A11", "56") + enter_text_to_cell(gridwin, "A12", "57") + enter_text_to_cell(gridwin, "A13", "26") + + + enter_text_to_cell(gridwin, "B1", "Physics") + enter_text_to_cell(gridwin, "B2", "67") + enter_text_to_cell(gridwin, "B3", "68") + enter_text_to_cell(gridwin, "B4", "65") + enter_text_to_cell(gridwin, "B5", "64") + enter_text_to_cell(gridwin, "B6", "38") + enter_text_to_cell(gridwin, "B7", "84") + enter_text_to_cell(gridwin, "B8", "80") + enter_text_to_cell(gridwin, "B9", "49") + enter_text_to_cell(gridwin, "B10", "49") + enter_text_to_cell(gridwin, "B11", "33") + + enter_text_to_cell(gridwin, "C1", "Biology") + enter_text_to_cell(gridwin, "C2", "33") + enter_text_to_cell(gridwin, "C3", "42") + enter_text_to_cell(gridwin, "C4", "44") + enter_text_to_cell(gridwin, "C5", "60") + enter_text_to_cell(gridwin, "C6", "43") + enter_text_to_cell(gridwin, "C7", "62") + enter_text_to_cell(gridwin, "C8", "51") + enter_text_to_cell(gridwin, "C9", "40") + enter_text_to_cell(gridwin, "C10", "12") + enter_text_to_cell(gridwin, "C11", "60") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C13"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:DescriptiveStatisticsDialog") as xDialog: + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$C$13"})) + + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$F$1"})) + + xgroupedbyrowsradio.executeAction("CLICK", tuple()) + xgroupedbycolumnsradio.executeAction("CLICK", tuple()) + + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString() , "Mean") + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString() , "Standard Error") + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString() , "Mode") + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString() , "Median") + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString() , "First Quartile") + self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString() , "Third Quartile") + self.assertEqual(get_cell_by_position(document, 0, 5, 7).getString() , "Variance") + self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString() , "Standard Deviation") + self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString() , "Kurtosis") + self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString() , "Skewness") + self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString() , "Range") + self.assertEqual(get_cell_by_position(document, 0, 5, 12).getString() , "Minimum") + self.assertEqual(get_cell_by_position(document, 0, 5, 13).getString() , "Maximum") + self.assertEqual(get_cell_by_position(document, 0, 5, 14).getString() , "Sum") + self.assertEqual(get_cell_by_position(document, 0, 5, 15).getString() , "Count") + + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString() , "Math") + self.assertEqual(round(get_cell_by_position(document, 0, 6, 1).getValue(),12) , 41.909090909091) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 2).getValue(),13) , 3.5610380137731) + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue() , 47) + self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue() , 40) + self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue() , 32.5) + self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue() , 51.5) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 7).getValue(),11) , 139.49090909091) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 8).getValue(),12) , 11.810626955878) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 9).getValue(),13) , -1.4621677980825) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 10).getValue(),13) , 0.0152409532904) + self.assertEqual(get_cell_by_position(document, 0, 6, 11).getValue() , 31) + self.assertEqual(get_cell_by_position(document, 0, 6, 12).getValue() , 26) + self.assertEqual(get_cell_by_position(document, 0, 6, 13).getValue() , 57) + self.assertEqual(get_cell_by_position(document, 0, 6, 14).getValue() , 461) + self.assertEqual(get_cell_by_position(document, 0, 6, 15).getValue() , 11) + + self.assertEqual(get_cell_by_position(document, 0, 7, 0).getString() , "Physics") + self.assertEqual(round(get_cell_by_position(document, 0, 7, 1).getValue(),1) , 59.7) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 2).getValue(),14) , 5.35837869343164) + self.assertEqual(get_cell_by_position(document, 0, 7, 3).getValue() , 49) + self.assertEqual(get_cell_by_position(document, 0, 7, 4).getValue() , 64.5) + self.assertEqual(get_cell_by_position(document, 0, 7, 5).getValue() , 49) + self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue() , 67.75) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 7).getValue(),11) , 287.12222222222) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 8).getValue(),12) , 16.944681236961) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 9).getValue(),14) , -0.94159887458526) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 10).getValue(),13) , -0.2226426904338) + self.assertEqual(get_cell_by_position(document, 0, 7, 11).getValue() , 51) + self.assertEqual(get_cell_by_position(document, 0, 7, 12).getValue() , 33) + self.assertEqual(get_cell_by_position(document, 0, 7, 13).getValue() , 84) + self.assertEqual(get_cell_by_position(document, 0, 7, 14).getValue() , 597) + self.assertEqual(get_cell_by_position(document, 0, 7, 15).getValue() , 10) + + self.assertEqual(get_cell_by_position(document, 0, 8, 0).getString() , "Biology") + self.assertEqual(get_cell_by_position(document, 0, 8, 1).getValue() , 44.7) + self.assertEqual(round(get_cell_by_position(document, 0, 8, 2).getValue(),13) , 4.7680650629416) + self.assertEqual(get_cell_by_position(document, 0, 8, 3).getValue() , 60) + self.assertEqual(get_cell_by_position(document, 0, 8, 4).getValue() , 43.5) + self.assertEqual(get_cell_by_position(document, 0, 8, 5).getValue() , 40.5) + self.assertEqual(get_cell_by_position(document, 0, 8, 6).getValue() , 57.75) + self.assertEqual(round(get_cell_by_position(document, 0, 8, 7).getValue(),11) , 227.34444444444) + self.assertEqual(round(get_cell_by_position(document, 0, 8, 8).getValue(),11) , 15.07794563077) + self.assertEqual(round(get_cell_by_position(document, 0, 8, 9).getValue(),12) , 1.418052718986) + self.assertEqual(round(get_cell_by_position(document, 0, 8, 10).getValue(),14) , -0.97668033725691) + self.assertEqual(get_cell_by_position(document, 0, 8, 11).getValue() , 50) + self.assertEqual(get_cell_by_position(document, 0, 8, 12).getValue() , 12) + self.assertEqual(get_cell_by_position(document, 0, 8, 13).getValue() , 62) + self.assertEqual(get_cell_by_position(document, 0, 8, 14).getValue() , 447) + self.assertEqual(get_cell_by_position(document, 0, 8, 15).getValue() , 10) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + + # test cancel button + with self.ui_test.execute_modeless_dialog_through_command(".uno:DescriptiveStatisticsDialog", close_button="cancel"): + pass + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/exponentialSmoothing.py b/sc/qa/uitest/statistics/exponentialSmoothing.py new file mode 100644 index 000000000..5823c3265 --- /dev/null +++ b/sc/qa/uitest/statistics/exponentialSmoothing.py @@ -0,0 +1,173 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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.calc import enter_text_to_cell + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class exponentialSmoothing(UITestCase): + def test_exponential_smoothing_column(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "0") + enter_text_to_cell(gridwin, "A3", "0") + enter_text_to_cell(gridwin, "A4", "0") + enter_text_to_cell(gridwin, "A5", "0") + enter_text_to_cell(gridwin, "A7", "0") + enter_text_to_cell(gridwin, "A8", "0") + enter_text_to_cell(gridwin, "A9", "0") + enter_text_to_cell(gridwin, "A10", "0") + enter_text_to_cell(gridwin, "A11", "0") + enter_text_to_cell(gridwin, "A12", "0") + enter_text_to_cell(gridwin, "A13", "0") + + enter_text_to_cell(gridwin, "B1", "0") + enter_text_to_cell(gridwin, "B2", "0") + enter_text_to_cell(gridwin, "B3", "1") + enter_text_to_cell(gridwin, "B4", "0") + enter_text_to_cell(gridwin, "B5", "0") + enter_text_to_cell(gridwin, "B6", "0") + enter_text_to_cell(gridwin, "B7", "0") + enter_text_to_cell(gridwin, "B8", "0") + enter_text_to_cell(gridwin, "B9", "0") + enter_text_to_cell(gridwin, "B10", "0") + enter_text_to_cell(gridwin, "B11", "0") + enter_text_to_cell(gridwin, "B12", "0") + enter_text_to_cell(gridwin, "B13", "0") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:ExponentialSmoothingDialog") as xDialog: + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xmoothingfactorspin = xDialog.getChild("smoothing-factor-spin") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) + xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"TEXT":"0.5"})) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Alpha") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), 0.5) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Column 1") + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getValue(), 0.5) + self.assertEqual(get_cell_by_position(document, 0, 5, 6).getValue(), 0.25) + self.assertEqual(get_cell_by_position(document, 0, 5, 7).getValue(), 0.125) + self.assertEqual(get_cell_by_position(document, 0, 5, 8).getValue(), 0.0625) + self.assertEqual(get_cell_by_position(document, 0, 5, 9).getValue(), 0.03125) + self.assertEqual(get_cell_by_position(document, 0, 5, 10).getValue(), 0.015625) + self.assertEqual(get_cell_by_position(document, 0, 5, 11).getValue(), 0.0078125) + self.assertEqual(get_cell_by_position(document, 0, 5, 12).getValue(), 0.00390625) + self.assertEqual(get_cell_by_position(document, 0, 5, 13).getValue(), 0.001953125) + self.assertEqual(get_cell_by_position(document, 0, 5, 14).getValue(), 0.0009765625) + self.assertEqual(get_cell_by_position(document, 0, 5, 15).getValue(), 0.00048828125) + self.assertEqual(get_cell_by_position(document, 0, 5, 16).getValue(), 0.000244140625) + + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getString(), "Column 2") + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 0.5) + self.assertEqual(get_cell_by_position(document, 0, 6, 7).getValue(), 0.25) + self.assertEqual(get_cell_by_position(document, 0, 6, 8).getValue(), 0.125) + self.assertEqual(get_cell_by_position(document, 0, 6, 9).getValue(), 0.0625) + self.assertEqual(get_cell_by_position(document, 0, 6, 10).getValue(), 0.03125) + self.assertEqual(get_cell_by_position(document, 0, 6, 11).getValue(), 0.015625) + self.assertEqual(get_cell_by_position(document, 0, 6, 12).getValue(), 0.0078125) + self.assertEqual(get_cell_by_position(document, 0, 6, 13).getValue(), 0.00390625) + self.assertEqual(get_cell_by_position(document, 0, 6, 14).getValue(), 0.001953125) + self.assertEqual(get_cell_by_position(document, 0, 6, 15).getValue(), 0.0009765625) + self.assertEqual(get_cell_by_position(document, 0, 6, 16).getValue(), 0.00048828125) + + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + + # test cancel button + with self.ui_test.execute_modeless_dialog_through_command(".uno:ExponentialSmoothingDialog", close_button="cancel"): + pass + + + def test_exponential_smoothing_row(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "0") + enter_text_to_cell(gridwin, "A3", "0") + enter_text_to_cell(gridwin, "A4", "0") + enter_text_to_cell(gridwin, "A5", "0") + enter_text_to_cell(gridwin, "A7", "0") + enter_text_to_cell(gridwin, "A8", "0") + enter_text_to_cell(gridwin, "A9", "0") + enter_text_to_cell(gridwin, "A10", "0") + enter_text_to_cell(gridwin, "A11", "0") + enter_text_to_cell(gridwin, "A12", "0") + enter_text_to_cell(gridwin, "A13", "0") + + enter_text_to_cell(gridwin, "B1", "0") + enter_text_to_cell(gridwin, "B2", "0") + enter_text_to_cell(gridwin, "B3", "1") + enter_text_to_cell(gridwin, "B4", "0") + enter_text_to_cell(gridwin, "B5", "0") + enter_text_to_cell(gridwin, "B6", "0") + enter_text_to_cell(gridwin, "B7", "0") + enter_text_to_cell(gridwin, "B8", "0") + enter_text_to_cell(gridwin, "B9", "0") + enter_text_to_cell(gridwin, "B10", "0") + enter_text_to_cell(gridwin, "B11", "0") + enter_text_to_cell(gridwin, "B12", "0") + enter_text_to_cell(gridwin, "B13", "0") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:ExponentialSmoothingDialog") as xDialog: + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xmoothingfactorspin = xDialog.getChild("smoothing-factor-spin") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) + xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"TEXT":"0.5"})) + xgroupedbyrowsradio.executeAction("CLICK", tuple()) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Alpha") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), 0.5) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Row 1") + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getValue(), 0.5) + + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getString(), "Row 2") + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue(), 0) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/fTest.py b/sc/qa/uitest/statistics/fTest.py new file mode 100644 index 000000000..058016373 --- /dev/null +++ b/sc/qa/uitest/statistics/fTest.py @@ -0,0 +1,111 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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.calc import enter_text_to_cell + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class tTest(UITestCase): + def test_fTest_column(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #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"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:FTestDialog") as xDialog: + xvariable1rangeedit = xDialog.getChild("variable1-range-edit") + xvariable2rangeedit = xDialog.getChild("variable2-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + 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()) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "F-test") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha") + + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Mean") + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Variance") + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Observations") + self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "df") + self.assertEqual(get_cell_by_position(document, 0, 5, 7).getString(), "F") + self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "P (F<=f) right-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "F Critical right-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "P (F<=f) left-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "F Critical left-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 12).getString(), "P two-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 13).getString(), "F 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).getString(), "Variable 1") + self.assertEqual(round(get_cell_by_position(document, 0, 6, 3).getValue(),12), 16.923076923077) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 4).getValue(),12), 125.076923076923) + self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue(), 13) + self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 12) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 7).getValue(),12), 1.324463752376) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 8).getValue(),12), 0.317061414639) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 9).getValue(),12), 2.686637112496) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 10).getValue(),12), 0.682938585361) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 12).getValue(),12), 0.634122829279) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 13).getValue(),12), 0.305131354874) + + self.assertEqual(get_cell_by_position(document, 0, 7, 2).getString(), "Variable 2") + self.assertEqual(round(get_cell_by_position(document, 0, 7, 3).getValue(),12), 20.461538461538) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 4).getValue(),12), 94.435897435897) + self.assertEqual(get_cell_by_position(document, 0, 7, 5).getValue(), 13) + self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue(), 12) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 13).getValue(),12), 3.277277094033) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + + # test cancel button + with self.ui_test.execute_modeless_dialog_through_command(".uno:FTestDialog", close_button="cancel"): + pass + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/movingAverage.py b/sc/qa/uitest/statistics/movingAverage.py new file mode 100644 index 000000000..4f5348d18 --- /dev/null +++ b/sc/qa/uitest/statistics/movingAverage.py @@ -0,0 +1,166 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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.calc import enter_text_to_cell + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class movingAverage(UITestCase): + def test_moving_average_column(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "0") + enter_text_to_cell(gridwin, "A3", "0") + enter_text_to_cell(gridwin, "A4", "0") + enter_text_to_cell(gridwin, "A5", "0") + enter_text_to_cell(gridwin, "A7", "0") + enter_text_to_cell(gridwin, "A8", "0") + enter_text_to_cell(gridwin, "A9", "0") + enter_text_to_cell(gridwin, "A10", "0") + enter_text_to_cell(gridwin, "A11", "0") + enter_text_to_cell(gridwin, "A12", "0") + enter_text_to_cell(gridwin, "A13", "0") + + enter_text_to_cell(gridwin, "B1", "0") + enter_text_to_cell(gridwin, "B2", "0") + enter_text_to_cell(gridwin, "B3", "1") + enter_text_to_cell(gridwin, "B4", "0") + enter_text_to_cell(gridwin, "B5", "0") + enter_text_to_cell(gridwin, "B6", "0") + enter_text_to_cell(gridwin, "B7", "0") + enter_text_to_cell(gridwin, "B8", "0") + enter_text_to_cell(gridwin, "B9", "0") + enter_text_to_cell(gridwin, "B10", "0") + enter_text_to_cell(gridwin, "B11", "0") + enter_text_to_cell(gridwin, "B12", "0") + enter_text_to_cell(gridwin, "B13", "0") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:MovingAverageDialog") as xDialog: + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xintervalspin = xDialog.getChild("interval-spin") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) + xintervalspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xintervalspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xintervalspin.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Column 1") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "#N/A") + self.assertEqual(round(get_cell_by_position(document, 0, 5, 2).getValue(),8), 0.33333333) + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 6).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 7).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 8).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 9).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 10).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 11).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 12).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 13).getString(), "#N/A") + + + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "Column 2") + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getString(), "#N/A") + self.assertEqual(round(get_cell_by_position(document, 0, 6, 2).getValue(),8), 0.33333333) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 3).getValue(),8), 0.33333333) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 4).getValue(),8), 0.33333333) + self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 7).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 9).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 10).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 11).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 12).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 13).getString(), "#N/A") + + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + + # test cancel button + with self.ui_test.execute_modeless_dialog_through_command(".uno:MovingAverageDialog", close_button="cancel"): + pass + + + def test_moving_average_row(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "0") + enter_text_to_cell(gridwin, "A3", "0") + enter_text_to_cell(gridwin, "A4", "0") + enter_text_to_cell(gridwin, "A5", "0") + enter_text_to_cell(gridwin, "A7", "0") + enter_text_to_cell(gridwin, "A8", "0") + enter_text_to_cell(gridwin, "A9", "0") + enter_text_to_cell(gridwin, "A10", "0") + enter_text_to_cell(gridwin, "A11", "0") + enter_text_to_cell(gridwin, "A12", "0") + enter_text_to_cell(gridwin, "A13", "0") + + enter_text_to_cell(gridwin, "B1", "0") + enter_text_to_cell(gridwin, "B2", "0") + enter_text_to_cell(gridwin, "B3", "1") + enter_text_to_cell(gridwin, "B4", "0") + enter_text_to_cell(gridwin, "B5", "0") + enter_text_to_cell(gridwin, "B6", "0") + enter_text_to_cell(gridwin, "B7", "0") + enter_text_to_cell(gridwin, "B8", "0") + enter_text_to_cell(gridwin, "B9", "0") + enter_text_to_cell(gridwin, "B10", "0") + enter_text_to_cell(gridwin, "B11", "0") + enter_text_to_cell(gridwin, "B12", "0") + enter_text_to_cell(gridwin, "B13", "0") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:MovingAverageDialog") as xDialog: + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xintervalspin = xDialog.getChild("interval-spin") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) + xintervalspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xintervalspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xintervalspin.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) + xgroupedbyrowsradio.executeAction("CLICK", tuple()) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Row 1") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "#N/A") + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "#N/A") + + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "Row 2") + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getString(), "#N/A") + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getString(), "#N/A") + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/regression.py b/sc/qa/uitest/statistics/regression.py new file mode 100644 index 000000000..dced52989 --- /dev/null +++ b/sc/qa/uitest/statistics/regression.py @@ -0,0 +1,104 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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, get_url_for_data_file + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class regression(UITestCase): + def test_regression_row(self): + self._regression_check(data_groupedby_column = False) + + def test_regression_column(self): + self._regression_check(data_groupedby_column = True) + + def _regression_check(self, data_groupedby_column = True): + with self.ui_test.load_file(get_url_for_data_file("regression.ods")) as calc_doc: + # Initially the final check status is "FALSE" (failed). + self.assertEqual(get_cell_by_position(calc_doc, 14, 1, 6).getString(), "FALSE", + "Check status must be FALSE before the test") + self._do_regression(regression_type = "LINEAR", data_groupedby_column = data_groupedby_column, calc_intercept = True) + self._do_regression(regression_type = "LINEAR", data_groupedby_column = data_groupedby_column, calc_intercept = False) + self._do_regression(regression_type = "LOG", data_groupedby_column = data_groupedby_column) + self._do_regression(regression_type = "POWER", data_groupedby_column = data_groupedby_column) + self.assertEqual(get_cell_by_position(calc_doc, 14, 1, 6).getString(), "TRUE", + "One of more of the checks failed for data_groupedby_column = {}, manually try with the calc_doc". + format(data_groupedby_column)) + + def _do_regression(self, regression_type, data_groupedby_column = True, calc_intercept = True): + assert(regression_type == "LINEAR" or regression_type == "LOG" or regression_type == "POWER") + with self.ui_test.execute_modeless_dialog_through_command(".uno:RegressionDialog") as xDialog: + xvariable1rangeedit = xDialog.getChild("variable1-range-edit") + xvariable2rangeedit = xDialog.getChild("variable2-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xwithlabelscheck = xDialog.getChild("withlabels-check") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + xlinearradio = xDialog.getChild("linear-radio") + xlogarithmicradio = xDialog.getChild("logarithmic-radio") + xpowerradio = xDialog.getChild("power-radio") + xnointerceptcheck = xDialog.getChild("nointercept-check") + + ## Set the X, Y and output ranges + xvariable1rangeedit.executeAction("FOCUS", tuple()) # Without this the range parser does not kick in somehow + xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + if data_groupedby_column: + xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$DataInColumns.$A$1:$C$11"})) + else: + xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$DataInRows.$A$1:$K$3"})) + + xvariable2rangeedit.executeAction("FOCUS", tuple()) # Without this the range parser does not kick in somehow + xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + if data_groupedby_column: + xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$DataInColumns.$D$1:$D$11"})) + else: + xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$DataInRows.$A$4:$K$4"})) + # The data ranges have labels in them + if (get_state_as_dict(xwithlabelscheck)["Selected"]) == "false": + xwithlabelscheck.executeAction("CLICK", tuple()) + + xoutputrangeedit.executeAction("FOCUS", tuple()) # Without this the range parser does not kick in somehow + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + if regression_type == "LINEAR": + if calc_intercept: + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$ActualLinear.$A$1"})) + else: + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$ActualLinearNoIntercept.$A$1"})) + elif regression_type == "LOG": + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$ActualLog.$A$1"})) + else: + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$ActualPower.$A$1"})) + + if data_groupedby_column: + xgroupedbycolumnsradio.executeAction("CLICK", tuple()) + else: + xgroupedbyrowsradio.executeAction("CLICK", tuple()) + + if regression_type == "LINEAR": + xlinearradio.executeAction("CLICK", tuple()) + elif regression_type == "LOG": + xlogarithmicradio.executeAction("CLICK", tuple()) + else: + xpowerradio.executeAction("CLICK", tuple()) + + if not calc_intercept: + xnointerceptcheck.executeAction("CLICK", tuple()) + + + def test_regression_cancel(self): + with self.ui_test.create_doc_in_start_center("calc"): + with self.ui_test.execute_modeless_dialog_through_command(".uno:RegressionDialog", close_button="cancel"): + pass + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/sampling.py b/sc/qa/uitest/statistics/sampling.py new file mode 100644 index 000000000..adcf6a5b7 --- /dev/null +++ b/sc/qa/uitest/statistics/sampling.py @@ -0,0 +1,147 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class sampling(UITestCase): + def test_statistic_sampling(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "11") + enter_text_to_cell(gridwin, "A2", "12") + enter_text_to_cell(gridwin, "A3", "13") + enter_text_to_cell(gridwin, "A4", "14") + enter_text_to_cell(gridwin, "A5", "15") + enter_text_to_cell(gridwin, "A6", "16") + enter_text_to_cell(gridwin, "A7", "17") + enter_text_to_cell(gridwin, "A8", "18") + enter_text_to_cell(gridwin, "A9", "19") + + enter_text_to_cell(gridwin, "B1", "21") + enter_text_to_cell(gridwin, "B2", "22") + enter_text_to_cell(gridwin, "B3", "23") + enter_text_to_cell(gridwin, "B4", "24") + enter_text_to_cell(gridwin, "B5", "25") + enter_text_to_cell(gridwin, "B6", "26") + enter_text_to_cell(gridwin, "B7", "27") + enter_text_to_cell(gridwin, "B8", "28") + enter_text_to_cell(gridwin, "B9", "29") + + enter_text_to_cell(gridwin, "C1", "31") + enter_text_to_cell(gridwin, "C2", "32") + enter_text_to_cell(gridwin, "C3", "33") + enter_text_to_cell(gridwin, "C4", "34") + enter_text_to_cell(gridwin, "C5", "35") + enter_text_to_cell(gridwin, "C6", "36") + enter_text_to_cell(gridwin, "C7", "37") + enter_text_to_cell(gridwin, "C8", "38") + enter_text_to_cell(gridwin, "C9", "39") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C9"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:SamplingDialog") as xDialog: + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xperiodicmethodradio = xDialog.getChild("periodic-method-radio") + xperiodspin = xDialog.getChild("period-spin") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$C$9"})) + + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$F$1"})) + + xperiodicmethodradio.executeAction("CLICK", tuple()) + + xperiodspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xperiodspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xperiodspin.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getValue(), 12) + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue() , 14) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue() , 16) + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue() , 18) + + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getValue(), 22) + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue() , 24) + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue() , 26) + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue() , 28) + + self.assertEqual(get_cell_by_position(document, 0, 7, 0).getValue(), 32) + self.assertEqual(get_cell_by_position(document, 0, 7, 1).getValue() , 34) + self.assertEqual(get_cell_by_position(document, 0, 7, 2).getValue() , 36) + self.assertEqual(get_cell_by_position(document, 0, 7, 3).getValue() , 38) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue() , 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue() , 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue() , 0) + + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue() , 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue() , 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue() , 0) + + self.assertEqual(get_cell_by_position(document, 0, 7, 0).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 7, 1).getValue() , 0) + self.assertEqual(get_cell_by_position(document, 0, 7, 2).getValue() , 0) + self.assertEqual(get_cell_by_position(document, 0, 7, 3).getValue() , 0) + + # test cancel button + with self.ui_test.execute_modeless_dialog_through_command(".uno:SamplingDialog", close_button="cancel"): + pass + + def test_tdf142986(self): + with self.ui_test.create_doc_in_start_center("calc") as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A200"})) + with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog: + xStartValue = xDialog.getChild("startValue") + xStartValue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xStartValue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xStartValue.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + + xIncrement = xDialog.getChild("increment") + xIncrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xIncrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xIncrement.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 199).getValue(), 200) + + with self.ui_test.execute_modeless_dialog_through_command(".uno:SamplingDialog") as xDialog: + xInputRangeEdit = xDialog.getChild("input-range-edit") + xOutputRangeEdit = xDialog.getChild("output-range-edit") + xRandomMethodRadio = xDialog.getChild("random-method-radio") + xSampleSizeSpin = xDialog.getChild("sample-size-spin") + + self.assertEqual("$Sheet1.$A$1:$A$200", get_state_as_dict(xInputRangeEdit)['Text']) + + xOutputRangeEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xOutputRangeEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xOutputRangeEdit.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$1"})) + + xRandomMethodRadio.executeAction("CLICK", tuple()) + + xSampleSizeSpin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSampleSizeSpin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xSampleSizeSpin.executeAction("TYPE", mkPropertyValues({"TEXT":"200"})) + + for i in range(200): + self.assertTrue(get_cell_by_position(calc_doc, 0, 1, i).getValue() != 0.0, + "Value in cell B" + str(i) + " shouldn't be equal to 0.0") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/tTest.py b/sc/qa/uitest/statistics/tTest.py new file mode 100644 index 000000000..1c7bc3a68 --- /dev/null +++ b/sc/qa/uitest/statistics/tTest.py @@ -0,0 +1,112 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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.calc import enter_text_to_cell + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class tTest(UITestCase): + def test_tTest_column(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #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"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:TTestDialog") as xDialog: + xvariable1rangeedit = xDialog.getChild("variable1-range-edit") + xvariable2rangeedit = xDialog.getChild("variable2-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + 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()) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Paired t-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(), "Mean") + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Variance") + self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "Observations") + self.assertEqual(get_cell_by_position(document, 0, 5, 7).getString(), "Pearson Correlation") + self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "Observed Mean Difference") + self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "Variance of the Differences") + self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "df") + self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "t Stat") + self.assertEqual(get_cell_by_position(document, 0, 5, 12).getString(), "P (T<=t) one-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 13).getString(), "t Critical one-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 14).getString(), "P (T<=t) two-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 15).getString(), "t 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(round(get_cell_by_position(document, 0, 6, 4).getValue(),12), 16.923076923077) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 5).getValue(),12), 125.076923076923) + self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 13) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 7).getValue(),12), -0.061753977175) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 8).getValue(),12), -3.538461538462) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 9).getValue(),12), 232.935897435897) + self.assertEqual(get_cell_by_position(document, 0, 6, 10).getValue(), 12) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 11).getValue(),12), -0.835926213674) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 12).getValue(),12), 0.209765144211) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 13).getValue(),12), 1.782287555649) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 14).getValue(),12), 0.419530288422) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 15).getValue(),12), 2.178812829667) + + self.assertEqual(get_cell_by_position(document, 0, 7, 3).getString(), "Variable 2") + self.assertEqual(round(get_cell_by_position(document, 0, 7, 4).getValue(),12), 20.461538461538) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 5).getValue(),12), 94.435897435897) + 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 + with self.ui_test.execute_modeless_dialog_through_command(".uno:TTestDialog", close_button="cancel"): + pass + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/tdf76731.py b/sc/qa/uitest/statistics/tdf76731.py new file mode 100644 index 000000000..9d10cd62c --- /dev/null +++ b/sc/qa/uitest/statistics/tdf76731.py @@ -0,0 +1,58 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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_url_for_data_file + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +# Bug 76731 - ANOVA: F critical is not shown +class anova(UITestCase): + def test_tdf76731_anova(self): + with self.ui_test.load_file(get_url_for_data_file("tdf76731.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #1. Open the attached sample document in Calc. + #2. Select the data range, i.e. A1:C5. + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C5"})) + #3. Choose Data - Analysis of Variance (ANOVA). + #4. Choose an arbitrary output cell and click OK. + with self.ui_test.execute_modeless_dialog_through_command(".uno:AnalysisOfVarianceDialog") as xDialog: + xoutputrangeedit = xDialog.getChild("output-range-edit") + xradiosinglefactor = xDialog.getChild("radio-single-factor") + xalphaspin = xDialog.getChild("alpha-spin") + + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) + xradiosinglefactor.executeAction("CLICK", tuple()) + xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xalphaspin.executeAction("TYPE", mkPropertyValues({"TEXT":"0.05"})) + #Verify, Table of results is shown, "F critical" cell has "#NAME?" error value. + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 0).getString(), "ANOVA - Single Factor") + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 1).getString(), "Alpha") + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 3).getString(), "Groups") + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 4).getString(), "Column 1") + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 5).getString(), "Column 2") + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 6).getString(), "Column 3") + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 8).getString(), "Source of Variation") + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 9).getString(), "Between Groups") + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 10).getString(), "Within Groups") + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 11).getString(), "Total") + + self.assertEqual(get_cell_by_position(calc_doc, 0, 11, 8).getString(), "F critical") + self.assertEqual(round(get_cell_by_position(calc_doc, 0, 11, 9).getValue(),9), 3.885293835) + + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 0).getString(), "") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/zTest.py b/sc/qa/uitest/statistics/zTest.py new file mode 100644 index 000000000..4ed285a9b --- /dev/null +++ b/sc/qa/uitest/statistics/zTest.py @@ -0,0 +1,102 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# 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.calc import enter_text_to_cell + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class zTest(UITestCase): + def test_zTest_column(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #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"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:ZTestDialog") as xDialog: + xvariable1rangeedit = xDialog.getChild("variable1-range-edit") + xvariable2rangeedit = xDialog.getChild("variable2-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + 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()) + #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 + with self.ui_test.execute_modeless_dialog_through_command(".uno:ZTestDialog", close_button="cancel"): + pass + +# vim: set shiftwidth=4 softtabstop=4 expandtab: |