[Libreoffice-commits] core.git: 11 commits - sc/qa uitest/libreoffice uitest/manual_tests uitest/uitest

Markus Mohrhard markus.mohrhard at googlemail.com
Thu Dec 22 03:11:28 UTC 2016


 sc/qa/extras/sccellrangeobj.cxx          |   26 +---
 uitest/libreoffice/calc/document.py      |    4 
 uitest/manual_tests/calc.py              |  176 +++++++++++++++++++++++++++++++
 uitest/manual_tests/data/cell_recalc.ods |binary
 uitest/uitest/test.py                    |   25 ++++
 5 files changed, 214 insertions(+), 17 deletions(-)

New commits:
commit c06be281e7bd97d8db5549cdc886c9761ac9c015
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Dec 22 01:13:07 2016 +0100

    uitest: convert random number manual test to automated testing
    
    http://manual-test.libreoffice.org/manage/case/143/
    
    Change-Id: Iff337668834cc729398a79719701627689b56dfd

diff --git a/uitest/manual_tests/calc.py b/uitest/manual_tests/calc.py
index bcc8f3c..2f7f5f4 100644
--- a/uitest/manual_tests/calc.py
+++ b/uitest/manual_tests/calc.py
@@ -192,4 +192,43 @@ class ManualCalcTests(UITestCase):
 
         self.ui_test.close_doc()
 
+    # http://manual-test.libreoffice.org/manage/case/143/
+    def test_random_numbers(self):
+        self.ui_test.create_doc_in_start_center("calc")
+        xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window")
+
+        xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A10"}))
+
+        self.ui_test.execute_modeless_dialog_through_command(".uno:RandomNumberGeneratorDialog")
+        xRandomNumberDlg = self.xUITest.getTopFocusWindow()
+        xDistributionLstBox = xRandomNumberDlg.getChild("distribution-combo")
+        xDistributionLstBox.executeAction("SELECT", mkPropertyValues({"POS": "1"}))
+
+        xMin = xRandomNumberDlg.getChild("parameter1-spin")
+        xMin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+A"}))
+        xMin.executeAction("TYPE", mkPropertyValues({"TEXT": "-2"}))
+        xMax = xRandomNumberDlg.getChild("parameter2-spin")
+        xMax.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+A"}))
+        xMax.executeAction("TYPE", mkPropertyValues({"TEXT": "10"}))
+
+        xApplyBtn = xRandomNumberDlg.getChild("apply")
+        xApplyBtn.executeAction("CLICK", tuple())
+
+        doc = self.ui_test.get_component()
+
+        def check_random_values():
+            for i in range(1, 9):
+                val = get_cell_by_position(doc, 0, 0, i).getValue()
+                self.assertTrue(val <= 10 and val >= -2)
+
+        check_random_values()
+
+        xOkBtn = xRandomNumberDlg.getChild("ok")
+        self.ui_test.close_dialog_through_button(xOkBtn)
+
+        # we might want to check that clicking 'ok' actually changes the values
+        check_random_values()
+
+        self.ui_test.close_doc()
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
commit ad5416b663ef647c289eb290195c1350242038fa
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Dec 22 00:47:54 2016 +0100

    uitest: convert cell recalculation manual test to automated testing
    
    http://manual-test.libreoffice.org/manage/case/151/
    
    Change-Id: I6b4e857eb949b29b03817058f8fb3a93ace13309

diff --git a/uitest/manual_tests/calc.py b/uitest/manual_tests/calc.py
index cbe2f8f..bcc8f3c 100644
--- a/uitest/manual_tests/calc.py
+++ b/uitest/manual_tests/calc.py
@@ -12,9 +12,13 @@ from libreoffice.calc.document import get_cell_by_position
 
 from uitest.uihelper.common import get_state_as_dict
 from uitest.uihelper.calc import enter_text_to_cell
+from uitest.path import get_srcdir_url
 
 import time
 
+def get_url_for_data_file(file_name):
+    return get_srcdir_url() + "/uitest/manual_tests/data/" + file_name
+
 class ManualCalcTests(UITestCase):
 
     # http://manual-test.libreoffice.org/manage/case/189/
@@ -169,4 +173,23 @@ class ManualCalcTests(UITestCase):
 
         self.ui_test.close_doc()
 
+    # http://manual-test.libreoffice.org/manage/case/151/
+    def test_cell_recalc(self):
+        doc = self.ui_test.load_file(get_url_for_data_file("cell_recalc.ods"))
+
+        xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window")
+        xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "D2:D9"}))
+        self.xUITest.executeCommand(".uno:Cut")
+
+        self.assertEqual(get_cell_by_position(doc, 0, 3, 15).getValue(), 0)
+
+        self.xUITest.executeCommand(".uno:Undo")
+
+        for i in range(1, 9):
+            self.assertTrue(get_cell_by_position(doc, 0, 3, i).getValue() != 0)
+
+        self.assertEqual(get_cell_by_position(doc, 0, 3, 15).getValue(), 195)
+
+        self.ui_test.close_doc()
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/uitest/manual_tests/data/cell_recalc.ods b/uitest/manual_tests/data/cell_recalc.ods
new file mode 100644
index 0000000..4b125fd
Binary files /dev/null and b/uitest/manual_tests/data/cell_recalc.ods differ
commit c3b36b460e71c4e3e0cd5eefcdc7b2b5340b502e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Dec 22 00:02:17 2016 +0100

    uitest: add reference to moztrap
    
    Change-Id: I5213a5a5356af8d80787dc023ac6eca64c456ff9

diff --git a/uitest/manual_tests/calc.py b/uitest/manual_tests/calc.py
index 76a81f0..cbe2f8f 100644
--- a/uitest/manual_tests/calc.py
+++ b/uitest/manual_tests/calc.py
@@ -100,6 +100,7 @@ class ManualCalcTests(UITestCase):
         time.sleep(2)
         self.ui_test.close_doc()
 
+    # http://manual-test.libreoffice.org/manage/case/191/
     def test_validation(self):
         self.ui_test.create_doc_in_start_center("calc")
 
@@ -131,6 +132,7 @@ class ManualCalcTests(UITestCase):
 
         self.ui_test.close_doc()
 
+    # http://manual-test.libreoffice.org/manage/case/187/
     def test_transpose(self):
         self.ui_test.create_doc_in_start_center("calc")
 
commit daca12903bb21f43468c3e96fa78bb881b956484
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Dec 22 00:01:07 2016 +0100

    uitest: convert transpose manual test to automated test
    
    http://manual-test.libreoffice.org/manage/case/187/
    
    Change-Id: Ia15514127c91ad9391329e96ad23e72b39f9b5f0

diff --git a/uitest/manual_tests/calc.py b/uitest/manual_tests/calc.py
index b0d7b2e..76a81f0 100644
--- a/uitest/manual_tests/calc.py
+++ b/uitest/manual_tests/calc.py
@@ -131,4 +131,40 @@ class ManualCalcTests(UITestCase):
 
         self.ui_test.close_doc()
 
+    def test_transpose(self):
+        self.ui_test.create_doc_in_start_center("calc")
+
+        xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window")
+        enter_text_to_cell(xGridWin, "B3", "abcd")
+        enter_text_to_cell(xGridWin, "B4", "edfg")
+        enter_text_to_cell(xGridWin, "C3", "35")
+        enter_text_to_cell(xGridWin, "C4", "5678")
+
+        xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C10"}))
+
+        self.xUITest.executeCommand(".uno:Cut")
+
+        xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
+
+        self.ui_test.execute_dialog_through_command(".uno:PasteSpecial")
+
+        xPasteSpecialDlg = self.xUITest.getTopFocusWindow()
+
+        xAllChkBox = xPasteSpecialDlg.getChild("paste_all")
+        xAllChkBox.executeAction("CLICK", tuple())
+
+        xTransposeChkBox = xPasteSpecialDlg.getChild("transpose")
+        xTransposeChkBox.executeAction("CLICK", tuple())
+
+        xOkBtn = xPasteSpecialDlg.getChild("ok")
+        self.ui_test.close_dialog_through_button(xOkBtn)
+
+        document = self.ui_test.get_component()
+        self.assertEqual(get_cell_by_position(document, 0, 2, 1).getString(), "abcd")
+        self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 35)
+        self.assertEqual(get_cell_by_position(document, 0, 3, 1).getString(), "edfg")
+        self.assertEqual(get_cell_by_position(document, 0, 3, 2).getValue(), 5678)
+
+        self.ui_test.close_doc()
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
commit e69d4c2f9294e11572ad76c59ddc55f286fbe77d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Dec 21 23:42:24 2016 +0100

    uitest: convert validation manual test to automated test
    
    http://manual-test.libreoffice.org/manage/case/191/
    
    Change-Id: I5aa3dfd87e3de66f12b2a73a8c67cb01cbb56244

diff --git a/uitest/manual_tests/calc.py b/uitest/manual_tests/calc.py
index 5feadb53..b0d7b2e 100644
--- a/uitest/manual_tests/calc.py
+++ b/uitest/manual_tests/calc.py
@@ -100,4 +100,35 @@ class ManualCalcTests(UITestCase):
         time.sleep(2)
         self.ui_test.close_doc()
 
+    def test_validation(self):
+        self.ui_test.create_doc_in_start_center("calc")
+
+        xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window")
+        xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C10"}))
+
+        self.ui_test.execute_dialog_through_command(".uno:Validation")
+        xValidationDlg = self.xUITest.getTopFocusWindow()
+
+        xAllowList = xValidationDlg.getChild("allow")
+        xAllowList.executeAction("SELECT", mkPropertyValues({"POS": "1"}))
+
+        xData = xValidationDlg.getChild("data")
+        xData.executeAction("SELECT", mkPropertyValues({"POS": "5"}))
+
+        xVal = xValidationDlg.getChild("max")
+        xVal.executeAction("TYPE", mkPropertyValues({"TEXT":"0"}))
+
+        xOkBtn = xValidationDlg.getChild("ok")
+        self.ui_test.close_dialog_through_button(xOkBtn)
+
+        def enter_text(cell, text):
+            enter_text_to_cell(xGridWin, cell, text)
+
+        self.ui_test.execute_blocking_action(enter_text, "ok", args=("A1", "abc"))
+        self.ui_test.execute_blocking_action(enter_text, "ok", args=("B6", "2.18"))
+
+        enter_text_to_cell(xGridWin, "C2", "24")
+
+        self.ui_test.close_doc()
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
commit ffd3a78206ae66bacd35bedc548d3d923ac070d0
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Dec 21 23:41:47 2016 +0100

    uitest: add a way to execute blocking actions
    
    Change-Id: I312a835fd8de82d5f31e6ba09105b22587c43513

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index d68a67e..0f8cee1 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -6,6 +6,7 @@
 #
 
 import time
+import threading
 from uitest.config import DEFAULT_SLEEP
 
 from libreoffice.uno.eventlistener import EventListener
@@ -151,4 +152,21 @@ class UITest(object):
                 time_ += DEFAULT_SLEEP
                 time.sleep(DEFAULT_SLEEP)
 
+    def execute_blocking_action(self, action, dialog_element, args = ()):
+        thread = threading.Thread(target=action, args=args)
+        with EventListener(self._xContext, ["DialogExecute", "ModelessDialogExecute"]) as event:
+            thread.start()
+            time_ = 0
+            while time_ < 30:
+                if event.executed:
+                    xDlg = self._xUITest.getTopFocusWindow()
+                    xUIElement = xDlg.getChild(dialog_element)
+                    xUIElement.executeAction("CLICK", tuple())
+                    thread.join()
+                    return
+
+                time_ += DEFAULT_SLEEP
+                time.sleep(DEFAULT_SLEEP)
+        raise DialogNotExecutedException("did not execute a dialog for a blocking action")
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
commit 02db166d5f45d659a992911292da452cdb475de0
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Dec 21 17:16:08 2016 +0100

    uitest: convert next manual calc test to an automatic one
    
    Converts http://manual-test.libreoffice.org/manage/case/190/
    
    Change-Id: I72fa202c55578f1163f0184fbedd8e470cee0ed7

diff --git a/uitest/manual_tests/calc.py b/uitest/manual_tests/calc.py
index db2f2b8..5feadb53 100644
--- a/uitest/manual_tests/calc.py
+++ b/uitest/manual_tests/calc.py
@@ -8,8 +8,10 @@
 from uitest.framework import UITestCase
 
 from libreoffice.uno.propertyvalue import mkPropertyValues
+from libreoffice.calc.document import get_cell_by_position
 
 from uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.calc import enter_text_to_cell
 
 import time
 
@@ -56,4 +58,46 @@ class ManualCalcTests(UITestCase):
 
         self.ui_test.close_doc()
 
+    # http://manual-test.libreoffice.org/manage/case/190/
+    def test_sort_data(self):
+        self.ui_test.create_doc_in_start_center("calc")
+
+        # Insert data
+        xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window")
+        enter_text_to_cell(xGridWin, "B1", "3")
+        enter_text_to_cell(xGridWin, "B2", "25")
+        enter_text_to_cell(xGridWin, "B3", "17")
+        enter_text_to_cell(xGridWin, "B4", "9")
+        enter_text_to_cell(xGridWin, "B5", "19")
+        enter_text_to_cell(xGridWin, "B6", "0")
+        enter_text_to_cell(xGridWin, "B7", "107")
+        enter_text_to_cell(xGridWin, "B8", "89")
+        enter_text_to_cell(xGridWin, "B9", "8")
+        enter_text_to_cell(xGridWin, "B10", "33")
+
+        xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B10"}))
+
+        # Execute "Sort" dialog
+        self.ui_test.execute_dialog_through_command(".uno:DataSort")
+        xSortDlg = self.xUITest.getTopFocusWindow()
+
+        xOkBtn = xSortDlg.getChild("ok")
+        self.ui_test.close_dialog_through_button(xOkBtn)
+
+        document = self.ui_test.get_component()
+
+        self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 0)
+        self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 3)
+        self.assertEqual(get_cell_by_position(document, 0, 1, 2).getValue(), 8)
+        self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 9)
+        self.assertEqual(get_cell_by_position(document, 0, 1, 4).getValue(), 17)
+        self.assertEqual(get_cell_by_position(document, 0, 1, 5).getValue(), 19)
+        self.assertEqual(get_cell_by_position(document, 0, 1, 6).getValue(), 25)
+        self.assertEqual(get_cell_by_position(document, 0, 1, 7).getValue(), 33)
+        self.assertEqual(get_cell_by_position(document, 0, 1, 8).getValue(), 89)
+        self.assertEqual(get_cell_by_position(document, 0, 1, 9).getValue(), 107)
+
+        time.sleep(2)
+        self.ui_test.close_doc()
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
commit 92654aafae9b5d7187b117da5b4b60f533d8a536
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Dec 21 17:14:54 2016 +0100

    uitest: add method to get first component
    
    Note that this method should be improved to allow selecting a specific
    component. However for now this works will all tests that start only one
    document.
    
    Change-Id: Iaba47b3dc5996abbfc3fca54dfefa48df5a603d8

diff --git a/uitest/uitest/test.py b/uitest/uitest/test.py
index 552071f..d68a67e 100644
--- a/uitest/uitest/test.py
+++ b/uitest/uitest/test.py
@@ -41,6 +41,13 @@ class UITest(object):
         frames = desktop.getFrames()
         return frames
 
+    def get_component(self):
+        desktop = self.get_desktop()
+        components = desktop.getComponents()
+        for component in components:
+            if component is not None:
+                return component
+
     def load_file(self, url):
         desktop = self.get_desktop()
         with EventListener(self._xContext, "OnLoad") as event:
commit 8c286ace812898690244556d2c2a348e5174a2ad
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Dec 21 17:14:18 2016 +0100

    uitest: add helper method to get XCell from UNO
    
    Change-Id: I1600a1e5d79b100a6469d9fa52c67e9e374258a2

diff --git a/uitest/libreoffice/calc/document.py b/uitest/libreoffice/calc/document.py
index eea8d65..a753242 100644
--- a/uitest/libreoffice/calc/document.py
+++ b/uitest/libreoffice/calc/document.py
@@ -8,4 +8,8 @@
 def get_sheet_from_doc(document, index):
     return document.getSheets().getByIndex(index)
 
+def get_cell_by_position(document, tab, column, row):
+    sheet = get_sheet_from_doc(document, tab)
+    return sheet.getCellByPosition(column, row)
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
commit 0257f7638b266302af1fb5f8afa8c13a745d3da8
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Dec 21 15:20:38 2016 +0100

    no need to catch exceptions in cppunit tests
    
    The framework already catches exceptions and will fail the test.
    
    Change-Id: I8adfb5033fe11f6fefb1799c044b0a5a0acf2cbb

diff --git a/sc/qa/extras/sccellrangeobj.cxx b/sc/qa/extras/sccellrangeobj.cxx
index 12e2864..3f61972 100644
--- a/sc/qa/extras/sccellrangeobj.cxx
+++ b/sc/qa/extras/sccellrangeobj.cxx
@@ -117,27 +117,19 @@ uno::Reference< uno::XInterface > ScCellRangeObj::getXCellRangeData()
 void ScCellRangeObj::testSortOOB()
 {
     uno::Reference<util::XSortable> xSortable(init(),UNO_QUERY_THROW);
-    try {
-        uno::Sequence<beans::PropertyValue> aEmptyDescriptor;
-        xSortable->sort(aEmptyDescriptor);
-    } catch (const uno::Exception &) {
-        CPPUNIT_FAIL("exception thrown during empty sort");
-    }
+    uno::Sequence<beans::PropertyValue> aEmptyDescriptor;
+    xSortable->sort(aEmptyDescriptor);
 
-    try {
-        uno::Sequence<beans::PropertyValue> aProps(1);
-        uno::Sequence<util::SortField> aSort(1);
+    uno::Sequence<beans::PropertyValue> aProps(1);
+    uno::Sequence<util::SortField> aSort(1);
 
-        aSort[0].Field = 0xffffff;
-        aSort[0].SortAscending = true;
+    aSort[0].Field = 0xffffff;
+    aSort[0].SortAscending = true;
 
-        aProps[0].Name = "SortFields";
-        aProps[0].Value = uno::makeAny(aSort);
+    aProps[0].Name = "SortFields";
+    aProps[0].Value = uno::makeAny(aSort);
 
-        xSortable->sort(aProps);
-    } catch (const uno::Exception &) {
-        CPPUNIT_FAIL("exception thrown during OOB sort");
-    }
+    xSortable->sort(aProps);
 }
 
 void ScCellRangeObj::setUp()
commit 0540064629e974b0569379988936989701159fdb
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Dec 21 15:02:26 2016 +0100

    uitest: add a reference to the corresponding manual test
    
    Change-Id: I47c3a3947a9b0557f0eabaef4521c0abc5b743c5

diff --git a/uitest/manual_tests/calc.py b/uitest/manual_tests/calc.py
index b4680d2..db2f2b8 100644
--- a/uitest/manual_tests/calc.py
+++ b/uitest/manual_tests/calc.py
@@ -15,6 +15,7 @@ import time
 
 class ManualCalcTests(UITestCase):
 
+    # http://manual-test.libreoffice.org/manage/case/189/
     def test_define_database_range(self):
 
         self.ui_test.create_doc_in_start_center("calc")


More information about the Libreoffice-commits mailing list