[Libreoffice-commits] core.git: basctl/Library_basctl.mk basctl/source sw/qa

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Sat May 23 08:03:33 UTC 2020


 basctl/Library_basctl.mk              |    1 
 basctl/source/basicide/baside2.hxx    |    3 ++
 basctl/source/basicide/baside2b.cxx   |    9 ++++++
 basctl/source/basicide/uiobject.cxx   |   51 ++++++++++++++++++++++++++++++++++
 basctl/source/basicide/uiobject.hxx   |   35 +++++++++++++++++++++++
 sw/qa/uitest/macro_tests/tdf124413.py |   11 +++++++
 6 files changed, 110 insertions(+)

New commits:
commit 1668d38a14e10f7433eed83b21c11f5e0f2915d6
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Mon May 18 17:32:21 2020 +0200
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Sat May 23 10:02:59 2020 +0200

    uitest: add wrapper for macro editor
    
    Change-Id: I729c5cdbc3ba925a0c08750eba199a400babba1e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94445
    Tested-by: Jenkins
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/basctl/Library_basctl.mk b/basctl/Library_basctl.mk
index acd12b474160..0a6e2fb3f3ac 100644
--- a/basctl/Library_basctl.mk
+++ b/basctl/Library_basctl.mk
@@ -97,6 +97,7 @@ $(eval $(call gb_Library_add_exception_objects,basctl,\
 	basctl/source/basicide/register \
 	basctl/source/basicide/sbxitem \
 	basctl/source/basicide/scriptdocument \
+	basctl/source/basicide/uiobject \
 	basctl/source/basicide/unomodel \
 	basctl/source/dlged/dlgedclip \
 	basctl/source/dlged/dlged \
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index 110e8f483388..49e9c3759f6d 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -63,6 +63,7 @@ void setTextEngineText (ExtTextEngine&, OUString const&);
 class EditorWindow final : public vcl::Window, public SfxListener
 {
 friend class CodeCompleteWindow;
+friend class EditorWindowUIObject;
 private:
     class ChangesListener;
 
@@ -151,6 +152,8 @@ public:
     void            UpdateSyntaxHighlighting ();
 
     bool            GetProcedureName(OUString const & rLine, OUString& rProcType, OUString& rProcName) const;
+
+    FactoryFunction GetUITestFactory() const override;
 };
 
 class BreakPointWindow final : public vcl::Window
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index a3f227f9a0ef..a1efc0bcd93c 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -62,6 +62,8 @@
 #include <vector>
 #include <com/sun/star/reflection/theCoreReflection.hpp>
 #include <unotools/charclass.hxx>
+#include "uiobject.hxx"
+
 
 namespace basctl
 {
@@ -240,6 +242,7 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) :
     bDelayHighlight(true),
     pCodeCompleteWnd(VclPtr<CodeCompleteWindow>::Create(this))
 {
+    set_id("EditorWindow");
     SetBackground(Wallpaper(rModulWindow.GetLayout().GetSyntaxBackgroundColor()));
     SetPointer( PointerStyle::Text );
     SetHelpId( HID_BASICIDE_EDITORWINDOW );
@@ -1359,6 +1362,12 @@ void EditorWindow::ForceSyntaxTimeout()
     aSyntaxIdle.Invoke();
 }
 
+FactoryFunction EditorWindow::GetUITestFactory() const
+{
+    return EditorWindowUIObject::create;
+}
+
+
 // BreakPointWindow
 
 BreakPointWindow::BreakPointWindow (vcl::Window* pParent, ModulWindow* pModulWindow)
diff --git a/basctl/source/basicide/uiobject.cxx b/basctl/source/basicide/uiobject.cxx
new file mode 100644
index 000000000000..80807d3a40a6
--- /dev/null
+++ b/basctl/source/basicide/uiobject.cxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ */
+
+#include <memory>
+#include "uiobject.hxx"
+#include <vcl/xtextedt.hxx>
+
+namespace basctl
+{
+EditorWindowUIObject::EditorWindowUIObject(const VclPtr<basctl::EditorWindow>& xEditorWindow)
+    : WindowUIObject(xEditorWindow)
+    , mxEditorWindow(xEditorWindow)
+{
+}
+
+StringMap EditorWindowUIObject::get_state()
+{
+    StringMap aMap = WindowUIObject::get_state();
+
+    ExtTextEngine* pEditEngine = mxEditorWindow->GetEditEngine();
+    sal_Int32 i, nParas;
+    OUStringBuffer aRes;
+    for (i = 0, nParas = pEditEngine->GetParagraphCount(); i < nParas; ++i)
+    {
+        aRes.append(pEditEngine->GetText(i));
+        aRes.append("\n");
+    }
+
+    aMap["Text"] = aRes.makeStringAndClear();
+
+    return aMap;
+}
+
+std::unique_ptr<UIObject> EditorWindowUIObject::create(vcl::Window* pWindow)
+{
+    basctl::EditorWindow* pEditorWindow = dynamic_cast<basctl::EditorWindow*>(pWindow);
+    assert(pEditorWindow);
+    return std::unique_ptr<UIObject>(new EditorWindowUIObject(pEditorWindow));
+}
+
+OUString EditorWindowUIObject::get_name() const { return "EditorWindowUIObject"; }
+
+} // namespace basctl
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/uiobject.hxx b/basctl/source/basicide/uiobject.hxx
new file mode 100644
index 000000000000..f3a1e5ec88f3
--- /dev/null
+++ b/basctl/source/basicide/uiobject.hxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ */
+
+#include <memory>
+#include <vcl/uitest/uiobject.hxx>
+#include "baside2.hxx"
+
+namespace basctl
+{
+class EditorWindow;
+
+class EditorWindowUIObject : public WindowUIObject
+{
+    VclPtr<basctl::EditorWindow> mxEditorWindow;
+
+public:
+    EditorWindowUIObject(const VclPtr<basctl::EditorWindow>& xEditorWindow);
+
+    virtual StringMap get_state() override;
+
+    static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+protected:
+    virtual OUString get_name() const override;
+};
+
+} // namespace basctl
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/uitest/macro_tests/tdf124413.py b/sw/qa/uitest/macro_tests/tdf124413.py
index 926c4a2afcd9..a8ab676b77d3 100644
--- a/sw/qa/uitest/macro_tests/tdf124413.py
+++ b/sw/qa/uitest/macro_tests/tdf124413.py
@@ -6,6 +6,7 @@
 #
 
 from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict
 
 class tdf124413(UITestCase):
 
@@ -19,6 +20,13 @@ class tdf124413(UITestCase):
         xEditBtn = xDialog.getChild("edit")
         xEditBtn.executeAction("CLICK", tuple())
 
+        resultText = "REM  *****  BASIC  *****\n\nSub Main\n\nEnd Sub\n"
+
+        xMacroWin = self.xUITest.getTopFocusWindow()
+        xEditWin = xMacroWin.getChild('EditorWindow')
+
+        self.assertEqual(get_state_as_dict(xEditWin)['Text'], resultText)
+
         self.xUITest.executeCommand(".uno:SelectAll")
         self.xUITest.executeCommand(".uno:Copy")
         self.xUITest.executeCommand(".uno:SelectAll")
@@ -29,4 +37,7 @@ class tdf124413(UITestCase):
         self.xUITest.executeCommand(".uno:Redo")
         self.xUITest.executeCommand(".uno:Undo")
         self.xUITest.executeCommand(".uno:Redo")
+
+        self.assertEqual(get_state_as_dict(xEditWin)['Text'], resultText)
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:


More information about the Libreoffice-commits mailing list