[Libreoffice-commits] core.git: sc/qa sc/source

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Sat May 16 12:43:42 UTC 2020


 sc/qa/uitest/calc_tests/data/navigator.ods |binary
 sc/qa/uitest/calc_tests8/navigator.py      |   83 +++++++++++++++++++++++++++++
 sc/source/ui/inc/navipi.hxx                |    3 +
 sc/source/ui/inc/uiobject.hxx              |   20 ++++++
 sc/source/ui/navipi/navipi.cxx             |    8 ++
 sc/source/ui/uitest/uiobject.cxx           |   44 +++++++++++++++
 6 files changed, 158 insertions(+)

New commits:
commit e9a2addb11c2421f389d983286e0d457cf82e3df
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Fri May 15 19:04:12 2020 +0200
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Sat May 16 14:43:02 2020 +0200

    uitest: sc: test navigator
    
    Change-Id: I7ea7076df4e84726dadcdf9161914a28371f4563
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94325
    Tested-by: Jenkins
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>

diff --git a/sc/qa/uitest/calc_tests/data/navigator.ods b/sc/qa/uitest/calc_tests/data/navigator.ods
new file mode 100644
index 000000000000..c487b1d6bc45
Binary files /dev/null and b/sc/qa/uitest/calc_tests/data/navigator.ods differ
diff --git a/sc/qa/uitest/calc_tests8/navigator.py b/sc/qa/uitest/calc_tests8/navigator.py
new file mode 100644
index 000000000000..6e6cc31b1e59
--- /dev/null
+++ b/sc/qa/uitest/calc_tests8/navigator.py
@@ -0,0 +1,83 @@
+#
+# 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 libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import get_state_as_dict
+from uitest.path import get_srcdir_url
+
+def get_url_for_data_file(file_name):
+    return get_srcdir_url() + "/sc/qa/uitest/calc_tests/data/" + file_name
+
+class navigator(UITestCase):
+
+    def test_rename_sheet(self):
+        self.ui_test.load_file(get_url_for_data_file("navigator.ods"))
+        xCalcDoc = self.xUITest.getTopFocusWindow()
+        xGridWin = xCalcDoc.getChild("grid_window")
+
+        self.xUITest.executeCommand(".uno:Sidebar")
+        xGridWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "ScNavigatorPanel"}))
+
+        xCalcDoc = self.xUITest.getTopFocusWindow()
+        xNavigatorPanel = xCalcDoc.getChild("NavigatorPanelParent")
+        xContentBox = xNavigatorPanel.getChild('contentbox')
+        xSheets = xContentBox.getChild("0")
+        self.assertEqual(get_state_as_dict(xSheets)['Text'], 'Sheets')
+        self.assertEqual(len(xSheets.getChildren()), 2)
+        self.assertEqual(get_state_as_dict(xSheets.getChild('0'))['Text'], 'Sheet1')
+        self.assertEqual(get_state_as_dict(xSheets.getChild('1'))['Text'], 'S2')
+        xRangeNames = xContentBox.getChild("1")
+        self.assertEqual(get_state_as_dict(xRangeNames)['Text'], 'Range names')
+        self.assertEqual(len(xRangeNames.getChildren()), 2)
+        self.assertEqual(get_state_as_dict(xRangeNames.getChild('0'))['Text'], 'first (Sheet1)')
+        self.assertEqual(get_state_as_dict(xRangeNames.getChild('1'))['Text'], 'second (Sheet1)')
+
+        #The document has one comment too
+        xComments = xContentBox.getChild("6")
+        self.assertEqual(get_state_as_dict(xComments)['Text'], 'Comments')
+        self.assertEqual(len(xComments.getChildren()), 1)
+        self.assertEqual(get_state_as_dict(xComments.getChild('0'))['Text'], 'Test Comment')
+
+        self.ui_test.execute_dialog_through_command(".uno:RenameTable")
+        xDialog = self.xUITest.getTopFocusWindow()
+        xname_entry = xDialog.getChild("name_entry")
+        xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT": "S1"}))
+        xOKBtn = xDialog.getChild("ok")
+        self.ui_test.close_dialog_through_button(xOKBtn)
+
+        xCalcDoc = self.xUITest.getTopFocusWindow()
+        xNavigatorPanel = xCalcDoc.getChild("NavigatorPanelParent")
+        xContentBox = xNavigatorPanel.getChild('contentbox')
+        xSheets = xContentBox.getChild("0")
+        self.assertEqual(get_state_as_dict(xSheets)['Text'], 'Sheets')
+        self.assertEqual(len(xSheets.getChildren()), 2)
+        self.assertEqual(get_state_as_dict(xSheets.getChild('0'))['Text'], 'S1')
+        self.assertEqual(get_state_as_dict(xSheets.getChild('1'))['Text'], 'S2')
+        xRangeNames = xContentBox.getChild("1")
+        self.assertEqual(get_state_as_dict(xRangeNames)['Text'], 'Range names')
+        self.assertEqual(len(xRangeNames.getChildren()), 2)
+        self.assertEqual(get_state_as_dict(xRangeNames.getChild('0'))['Text'], 'first (S1)')
+        self.assertEqual(get_state_as_dict(xRangeNames.getChild('1'))['Text'], 'second (S1)')
+
+        self.xUITest.executeCommand(".uno:Undo")
+
+        xCalcDoc = self.xUITest.getTopFocusWindow()
+        xNavigatorPanel = xCalcDoc.getChild("NavigatorPanelParent")
+        xContentBox = xNavigatorPanel.getChild('contentbox')
+        xSheets = xContentBox.getChild("0")
+        self.assertEqual(get_state_as_dict(xSheets)['Text'], 'Sheets')
+        self.assertEqual(len(xSheets.getChildren()), 2)
+        self.assertEqual(get_state_as_dict(xSheets.getChild('0'))['Text'], 'Sheet1')
+        self.assertEqual(get_state_as_dict(xSheets.getChild('1'))['Text'], 'S2')
+        xRangeNames = xContentBox.getChild("1")
+        self.assertEqual(get_state_as_dict(xRangeNames)['Text'], 'Range names')
+        self.assertEqual(len(xRangeNames.getChildren()), 2)
+        #FIXME: tdf#133082
+        #self.assertEqual(get_state_as_dict(xRangeNames.getChild('0'))['Text'], 'first (Sheet1)')
+        #self.assertEqual(get_state_as_dict(xRangeNames.getChild('1'))['Text'], 'second (Sheet1)')
+
+        self.xUITest.executeCommand(".uno:Sidebar")
+        self.ui_test.close_doc()
diff --git a/sc/source/ui/inc/navipi.hxx b/sc/source/ui/inc/navipi.hxx
index a49cad057299..d93642cfcacf 100644
--- a/sc/source/ui/inc/navipi.hxx
+++ b/sc/source/ui/inc/navipi.hxx
@@ -89,6 +89,7 @@ class ScNavigatorDlg : public PanelLayout, public SfxListener
 friend class ScNavigatorControllerItem;
 friend class ScNavigatorDialogWrapper;
 friend class ScContentTree;
+friend class ScNavigatorDlgUIObject;
 
 private:
     static constexpr int CTRL_ITEMS = 4;
@@ -177,6 +178,8 @@ public:
     virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
 
     virtual void StateChanged(StateChangedType nStateChange) override;
+
+    FactoryFunction GetUITestFactory() const override;
 };
 
 class ScNavigatorDialogWrapper: public SfxChildWindowContext
diff --git a/sc/source/ui/inc/uiobject.hxx b/sc/source/ui/inc/uiobject.hxx
index b316aa58a13c..3f92943293f2 100644
--- a/sc/source/ui/inc/uiobject.hxx
+++ b/sc/source/ui/inc/uiobject.hxx
@@ -45,4 +45,24 @@ private:
     ScTabViewShell* getViewShell();
 };
 
+class ScNavigatorDlg;
+
+class ScNavigatorDlgUIObject : public WindowUIObject
+{
+    VclPtr<ScNavigatorDlg> mxScNavigatorDlg;
+
+public:
+
+    ScNavigatorDlgUIObject(const VclPtr<ScNavigatorDlg>& xScNavigatorDlg);
+
+    virtual void execute(const OUString& rAction,
+            const StringMap& rParameters) override;
+
+    static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+protected:
+
+    virtual OUString get_name() const override;
+};
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/navipi/navipi.cxx b/sc/source/ui/navipi/navipi.cxx
index 451ecb09708c..ab4e73f2cc91 100644
--- a/sc/source/ui/navipi/navipi.cxx
+++ b/sc/source/ui/navipi/navipi.cxx
@@ -24,6 +24,7 @@
 #include <sfx2/navigat.hxx>
 #include <svl/stritem.hxx>
 #include <unotools/charclass.hxx>
+#include <uiobject.hxx>
 
 #include <viewdata.hxx>
 #include <tabvwsh.hxx>
@@ -336,6 +337,8 @@ ScNavigatorDlg::ScNavigatorDlg(SfxBindings* pB, vcl::Window* pParent)
     , nCurRow(0)
     , nCurTab(0)
 {
+    set_id("NavigatorPanelParent"); // for uitests
+
     m_xEdRow->set_range(1, SCNAV_MAXROW);
     m_xEdRow->set_width_chars(5);
     //max rows is 1,000,000, which is too long for typical use
@@ -423,6 +426,11 @@ void ScNavigatorDlg::StateChanged(StateChangedType nStateChange)
     }
 }
 
+FactoryFunction ScNavigatorDlg::GetUITestFactory() const
+{
+    return ScNavigatorDlgUIObject::create;
+}
+
 ScNavigatorDlg::~ScNavigatorDlg()
 {
     disposeOnce();
diff --git a/sc/source/ui/uitest/uiobject.cxx b/sc/source/ui/uitest/uiobject.cxx
index 58aef21c8e8b..d52a8a75e6ab 100644
--- a/sc/source/ui/uitest/uiobject.cxx
+++ b/sc/source/ui/uitest/uiobject.cxx
@@ -17,6 +17,9 @@
 #include <dbfunc.hxx>
 #include <tabvwsh.hxx>
 #include <drwlayer.hxx>
+#include <navipi.hxx>
+#include <sfx2/sidebar/Sidebar.hxx>
+#include <sfx2/viewfrm.hxx>
 
 #include <svx/svditer.hxx>
 #include <svx/svdobj.hxx>
@@ -205,6 +208,19 @@ void ScGridWinUIObject::execute(const OUString& rAction,
             mxGridWindow->LaunchAutoFilterMenu(nCol, nRow);
         }
     }
+    else if (rAction == "SIDEBAR")
+    {
+        SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+        DBG_ASSERT(pViewFrm, "ScGridWinUIObject::execute: no viewframe");
+        pViewFrm->ShowChildWindow(SID_SIDEBAR);
+
+        auto itr = rParameters.find("PANEL");
+        if (itr != rParameters.end())
+        {
+            OUString aVal = itr->second;
+            ::sfx2::sidebar::Sidebar::ShowPanel(aVal, pViewFrm->GetFrame().GetFrameInterface());
+        }
+    }
     else
     {
         WindowUIObject::execute(rAction, rParameters);
@@ -274,4 +290,32 @@ OUString ScGridWinUIObject::get_name() const
     return "ScGridWinUIObject";
 }
 
+ScNavigatorDlgUIObject::ScNavigatorDlgUIObject(const VclPtr<ScNavigatorDlg>& xScNavigatorDlg):
+    WindowUIObject(xScNavigatorDlg),
+    mxScNavigatorDlg(xScNavigatorDlg)
+{
+}
+
+void ScNavigatorDlgUIObject::execute(const OUString& rAction,
+        const StringMap& rParameters)
+{
+    if (rAction == "ROOT")
+    {
+        mxScNavigatorDlg->ToolBoxSelectHdl("toggle");
+    }
+    else
+        WindowUIObject::execute(rAction, rParameters);
+}
+
+std::unique_ptr<UIObject> ScNavigatorDlgUIObject::create(vcl::Window* pWindow)
+{
+    ScNavigatorDlg* pScNavigatorDlg = dynamic_cast<ScNavigatorDlg*>(pWindow);
+    assert(pScNavigatorDlg);
+    return std::unique_ptr<UIObject>(new ScNavigatorDlgUIObject(pScNavigatorDlg));
+}
+
+OUString ScNavigatorDlgUIObject::get_name() const
+{
+    return "ScNavigatorDlgUIObject";
+}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list