[Libreoffice-commits] core.git: include/vcl vcl/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Sun Jan 7 17:07:32 UTC 2018
include/vcl/uitest/uiobject.hxx | 21 ++++++++++++++
include/vcl/vclmedit.hxx | 46 +++++++++++++++++++++++++++++++
vcl/source/edit/vclmedit.cxx | 52 +++++++----------------------------
vcl/source/uitest/uiobject.cxx | 58 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 135 insertions(+), 42 deletions(-)
New commits:
commit e66a0d7095260c62b067541a0c47ce5c07074f18
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Jan 7 14:23:31 2018 +0100
uitest: add support for GtkTextView/VclMultiLineEdit
Change-Id: If1f22ee562b73a54042985254e0b9cd127025b55
Reviewed-on: https://gerrit.libreoffice.org/47529
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/include/vcl/uitest/uiobject.hxx b/include/vcl/uitest/uiobject.hxx
index de413107903e..0493cbc19c98 100644
--- a/include/vcl/uitest/uiobject.hxx
+++ b/include/vcl/uitest/uiobject.hxx
@@ -192,6 +192,27 @@ protected:
virtual OUString get_name() const override;
};
+class UITEST_DLLPUBLIC MultiLineEditUIObject : public WindowUIObject
+{
+ VclPtr<VclMultiLineEdit> mxEdit;
+
+public:
+
+ MultiLineEditUIObject(const VclPtr<VclMultiLineEdit>& xEdit);
+ virtual ~MultiLineEditUIObject() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ virtual StringMap get_state() override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+protected:
+
+ virtual OUString get_name() const override;
+};
+
// TODO: moggi: maybe let it inherit from the button case
class UITEST_DLLPUBLIC CheckBoxUIObject : public WindowUIObject
{
diff --git a/include/vcl/vclmedit.hxx b/include/vcl/vclmedit.hxx
index 03f0b5667968..7caf3662aa0e 100644
--- a/include/vcl/vclmedit.hxx
+++ b/include/vcl/vclmedit.hxx
@@ -31,6 +31,47 @@ class Timer;
class ExtTextEngine;
class TextView;
+class TextWindow : public vcl::Window
+{
+private:
+ VclPtr<Edit> mxParent;
+ ExtTextEngine* mpExtTextEngine;
+ TextView* mpExtTextView;
+
+ bool mbInMBDown;
+ bool mbFocusSelectionHide;
+ bool mbIgnoreTab;
+ bool mbActivePopup;
+ bool mbSelectOnTab;
+
+public:
+ explicit TextWindow(Edit* pParent);
+ virtual ~TextWindow() override;
+ virtual void dispose() override;
+
+ ExtTextEngine* GetTextEngine() const { return mpExtTextEngine; }
+ TextView* GetTextView() const { return mpExtTextView; }
+
+ virtual void MouseMove( const MouseEvent& rMEvt ) override;
+ virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
+ virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
+ virtual void KeyInput( const KeyEvent& rKEvent ) override;
+
+ virtual void Command( const CommandEvent& rCEvt ) override;
+
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
+ virtual void Resize() override;
+
+ virtual void GetFocus() override;
+ virtual void LoseFocus() override;
+
+ void SetAutoFocusHide( bool bAutoHide ) { mbFocusSelectionHide = bAutoHide; }
+
+ void SetIgnoreTab( bool bIgnore ) { mbIgnoreTab = bIgnore; }
+
+ void DisableSelectionOnFocus() { mbSelectOnTab = false; }
+};
+
class VCL_DLLPUBLIC VclMultiLineEdit : public Edit
{
friend class VCLXAccessibleEdit;
@@ -55,8 +96,8 @@ protected:
void ImplInitSettings( bool bBackground );
static WinBits ImplInitStyle( WinBits nStyle );
- ExtTextEngine* GetTextEngine() const;
TextView* GetTextView() const;
+ ExtTextEngine* GetTextEngine() const;
ScrollBar* GetVScrollBar() const;
virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
@@ -133,6 +174,9 @@ public:
void EnableCursor( bool bEnable );
+ TextWindow* GetTextWindow();
+ virtual FactoryFunction GetUITestFactory() const override;
+
virtual bool set_property(const OString &rKey, const OUString &rValue) override;
};
diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx
index de34176ea07e..66fb2b058d72 100644
--- a/vcl/source/edit/vclmedit.cxx
+++ b/vcl/source/edit/vclmedit.cxx
@@ -26,52 +26,12 @@
#include <vcl/xtextedt.hxx>
#include <svl/undo.hxx>
#include <svl/lstner.hxx>
+#include <vcl/uitest/uiobject.hxx>
#include <strings.hrc>
#include <vcl/scrbar.hxx>
#include <vcl/settings.hxx>
-class TextWindow : public vcl::Window
-{
-private:
- VclPtr<Edit> mxParent;
- ExtTextEngine* mpExtTextEngine;
- TextView* mpExtTextView;
-
- bool mbInMBDown;
- bool mbFocusSelectionHide;
- bool mbIgnoreTab;
- bool mbActivePopup;
- bool mbSelectOnTab;
-
-public:
- explicit TextWindow(Edit* pParent);
- virtual ~TextWindow() override;
- virtual void dispose() override;
-
- ExtTextEngine* GetTextEngine() const { return mpExtTextEngine; }
- TextView* GetTextView() const { return mpExtTextView; }
-
- virtual void MouseMove( const MouseEvent& rMEvt ) override;
- virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
- virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
- virtual void KeyInput( const KeyEvent& rKEvent ) override;
-
- virtual void Command( const CommandEvent& rCEvt ) override;
-
- virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
- virtual void Resize() override;
-
- virtual void GetFocus() override;
- virtual void LoseFocus() override;
-
- void SetAutoFocusHide( bool bAutoHide ) { mbFocusSelectionHide = bAutoHide; }
-
- void SetIgnoreTab( bool bIgnore ) { mbIgnoreTab = bIgnore; }
-
- void DisableSelectionOnFocus() { mbSelectOnTab = false; }
-};
-
class ImpVclMEdit : public SfxListener
{
private:
@@ -1590,6 +1550,16 @@ void VclMultiLineEdit::EnableCursor( bool bEnable )
GetTextView()->EnableCursor( bEnable );
}
+TextWindow* VclMultiLineEdit::GetTextWindow()
+{
+ return pImpVclMEdit->GetTextWindow();
+}
+
+FactoryFunction VclMultiLineEdit::GetUITestFactory() const
+{
+ return MultiLineEditUIObject::create;
+}
+
bool VclMultiLineEdit::set_property(const OString &rKey, const OUString &rValue)
{
if (rKey == "cursor-visible")
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index 9fe9035e2e6a..56373981be74 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -18,6 +18,7 @@
#include <vcl/button.hxx>
#include <vcl/dialog.hxx>
#include <vcl/edit.hxx>
+#include <vcl/vclmedit.hxx>
#include <comphelper/string.hxx>
@@ -670,6 +671,63 @@ std::unique_ptr<UIObject> EditUIObject::create(vcl::Window* pWindow)
return std::unique_ptr<UIObject>(new EditUIObject(pEdit));
}
+MultiLineEditUIObject::MultiLineEditUIObject(const VclPtr<VclMultiLineEdit>& xEdit):
+ WindowUIObject(xEdit),
+ mxEdit(xEdit)
+{
+}
+
+MultiLineEditUIObject::~MultiLineEditUIObject()
+{
+}
+
+void MultiLineEditUIObject::execute(const OUString& rAction,
+ const StringMap& rParameters)
+{
+ bool bHandled = true;
+ if (rAction == "TYPE")
+ {
+ WindowUIObject aChildObj(mxEdit->GetTextWindow());
+ aChildObj.execute(rAction, rParameters);
+ }
+ else if (rAction == "SELECT")
+ {
+ if (rParameters.find("FROM") != rParameters.end() &&
+ rParameters.find("TO") != rParameters.end())
+ {
+ long nMin = rParameters.find("FROM")->second.toInt32();
+ long nMax = rParameters.find("TO")->second.toInt32();
+ Selection aSelection(nMin, nMax);
+ mxEdit->SetSelection(aSelection);
+ }
+ }
+
+ if (!bHandled)
+ WindowUIObject::execute(rAction, rParameters);
+}
+
+StringMap MultiLineEditUIObject::get_state()
+{
+ StringMap aMap = WindowUIObject::get_state();
+ aMap["MaxTextLength"] = OUString::number(mxEdit->GetMaxTextLen());
+ aMap["SelectedText"] = mxEdit->GetSelected();
+ aMap["Text"] = mxEdit->GetText();
+
+ return aMap;
+}
+
+OUString MultiLineEditUIObject::get_name() const
+{
+ return OUString("MultiLineEditUIObject");
+}
+
+std::unique_ptr<UIObject> MultiLineEditUIObject::create(vcl::Window* pWindow)
+{
+ VclMultiLineEdit* pEdit = dynamic_cast<VclMultiLineEdit*>(pWindow);
+ assert(pEdit);
+ return std::unique_ptr<UIObject>(new MultiLineEditUIObject(pEdit));
+}
+
CheckBoxUIObject::CheckBoxUIObject(const VclPtr<CheckBox>& xCheckbox):
WindowUIObject(xCheckbox),
mxCheckBox(xCheckbox)
More information about the Libreoffice-commits
mailing list