sc/qa/uitest/calc_tests9/pivotTable.py |   35 ++++++++++++++++++++++++++++++++-
 sc/qa/uitest/data/pivotTable.ods       |binary
 sc/source/ui/uitest/uiobject.cxx       |   19 +++++++++++++++++
 3 files changed, 53 insertions(+), 1 deletion(-)

New commits:
commit 35d9d085436e159bdeb6cba9c94865d6346af530
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon Nov 15 21:07:01 2021 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Nov 15 22:32:54 2021 +0100

    uitest: sc: add support for pivot table popup
    
    Change-Id: Id990178051e81a81bf6f6a0fb920473d3ee21fff
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125259
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/uitest/calc_tests9/pivotTable.py 
b/sc/qa/uitest/calc_tests9/pivotTable.py
index b7a4fd328b2a..559073ab0507 100644
--- a/sc/qa/uitest/calc_tests9/pivotTable.py
+++ b/sc/qa/uitest/calc_tests9/pivotTable.py
@@ -7,10 +7,11 @@
 from uitest.framework import UITestCase
 from libreoffice.uno.propertyvalue import mkPropertyValues
 from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
+from libreoffice.calc.document import get_cell_by_position
 
 class pivotTable(UITestCase):
 
-   def test_cancelButton(self):
+    def test_cancelButton(self):
 
         # This is basically a test for cf93998eb5abc193d95ae5433bf4dfd11a9d62d8
         # Without the fix in place, this test would have crashed
@@ -60,4 +61,36 @@ class pivotTable(UITestCase):
 
                         self.assertEqual('true', 
get_state_as_dict(xEmptyLine)['Selected'])
 
+    def test_popup(self):
+        with self.ui_test.load_file(get_url_for_data_file("pivotTable.ods")) 
as calc_doc:
+
+            xCalcDoc = self.xUITest.getTopFocusWindow()
+            gridwin = xCalcDoc.getChild("grid_window")
+
+            self.assertEqual("a", get_cell_by_position(calc_doc, 0, 3, 
1).getString())
+            self.assertEqual("b", get_cell_by_position(calc_doc, 0, 3, 
2).getString())
+            self.assertEqual("m", get_cell_by_position(calc_doc, 0, 4, 
1).getString())
+            self.assertEqual("n", get_cell_by_position(calc_doc, 0, 4, 
2).getString())
+            self.assertEqual("1", get_cell_by_position(calc_doc, 0, 5, 
1).getString())
+            self.assertEqual("1", get_cell_by_position(calc_doc, 0, 5, 
2).getString())
+
+            gridwin.executeAction("LAUNCH", mkPropertyValues({"PIVOTTABLE": 
"", "COL": "3", "ROW": "0"}))
+            xFloatWindow = self.xUITest.getFloatWindow()
+            xCheckListMenu = xFloatWindow.getChild("check_list_menu")
+
+            xTreeList = xCheckListMenu.getChild("check_list_box")
+            xFirstEntry = xTreeList.getChild("0")
+
+            xFirstEntry.executeAction("CLICK", tuple())
+
+            xOkBtn = xFloatWindow.getChild("ok")
+            xOkBtn.executeAction("CLICK", tuple())
+
+            self.assertEqual("b", get_cell_by_position(calc_doc, 0, 3, 
1).getString())
+            self.assertEqual("Total Result", get_cell_by_position(calc_doc, 0, 
3, 2).getString())
+            self.assertEqual("n", get_cell_by_position(calc_doc, 0, 4, 
1).getString())
+            self.assertEqual("", get_cell_by_position(calc_doc, 0, 4, 
2).getString())
+            self.assertEqual("1", get_cell_by_position(calc_doc, 0, 5, 
1).getString())
+            self.assertEqual("1", get_cell_by_position(calc_doc, 0, 5, 
2).getString())
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/data/pivotTable.ods b/sc/qa/uitest/data/pivotTable.ods
new file mode 100644
index 000000000000..cbb773857605
Binary files /dev/null and b/sc/qa/uitest/data/pivotTable.ods differ
diff --git a/sc/source/ui/uitest/uiobject.cxx b/sc/source/ui/uitest/uiobject.cxx
index d93da2619a77..14e464c0bf20 100644
--- a/sc/source/ui/uitest/uiobject.cxx
+++ b/sc/source/ui/uitest/uiobject.cxx
@@ -234,6 +234,25 @@ void ScGridWinUIObject::execute(const OUString& rAction,
             SCCOL nCol = itrCol->second.toUInt32();
             mxGridWindow->LaunchAutoFilterMenu(nCol, nRow);
         }
+        else if ( rParameters.find("PIVOTTABLE") != rParameters.end())
+        {
+            auto itrCol = rParameters.find("COL");
+            if (itrCol == rParameters.end())
+            {
+                SAL_WARN("sc.uitest", "missing COL parameter");
+                return;
+            }
+
+            auto itrRow = rParameters.find("ROW");
+            if (itrRow == rParameters.end())
+            {
+                SAL_WARN("sc.uitest", "missing ROW parameter");
+                return;
+            }
+            SCROW nRow = itrRow->second.toUInt32();
+            SCCOL nCol = itrCol->second.toUInt32();
+            mxGridWindow->LaunchDPFieldMenu(nCol, nRow);
+        }
         else if ( rParameters.find("SELECTMENU") != rParameters.end())
         {
             auto itrCol = rParameters.find("COL");

Reply via email to