summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShiko <aelshreif7@gmail.com>2020-06-12 17:58:05 +0200
committerAhmed ElShreif <aelshreif7@gmail.com>2020-06-17 21:35:01 +0200
commit75704068032174bde83c995e445342faaa04b9c7 (patch)
tree768bc7674a3517d30bdd2ac9349ff124c9f9355a
parent2ef9f5c15be1cb8f296ac4a3281e4ff10187aeeb (diff)
uitest: Add support for Writer comments
Change-Id: I88ed2894c3665fb421c5d8ea0f278c54ccd0d0e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96230 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--sw/inc/AnnotationWin.hxx3
-rw-r--r--sw/source/uibase/docvw/AnnotationWin.cxx9
-rw-r--r--sw/source/uibase/inc/uiobject.hxx23
-rw-r--r--sw/source/uibase/uitest/uiobject.cxx75
4 files changed, 110 insertions, 0 deletions
diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index 080d8de42ef0..715d01ea95ee 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -102,6 +102,7 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin : public vcl::Window
SwSidebarItem& GetSidebarItem() { return mrSidebarItem; }
OutlinerView* GetOutlinerView() { return mpOutlinerView.get();}
+ Outliner* GetOutliner() { return mpOutliner.get();}
bool HasScrollbar() const;
bool IsScrollbarVisible() const;
ScrollBar* Scrollbar() { return mpVScrollbar; }
@@ -198,6 +199,8 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin : public vcl::Window
/// This may be the same annotation as this one.
SwAnnotationWin* GetTopReplyNote();
+ virtual FactoryFunction GetUITestFactory() const override;
+
private:
VclPtr<MenuButton> CreateMenuButton();
virtual void LoseFocus() override;
diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx b/sw/source/uibase/docvw/AnnotationWin.cxx
index da900ec54237..29a7e6cac33f 100644
--- a/sw/source/uibase/docvw/AnnotationWin.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin.cxx
@@ -24,6 +24,8 @@
#include <strings.hrc>
+#include <uiobject.hxx>
+
#include <vcl/edit.hxx>
#include <vcl/menu.hxx>
#include <vcl/scrbar.hxx>
@@ -100,6 +102,8 @@ SwAnnotationWin::SwAnnotationWin( SwEditWin& rEditWin,
, mpField( static_cast<SwPostItField*>(aField->GetField()))
, mpButtonPopup(nullptr)
{
+ set_id("Comment"+OUString::number(mpField->GetPostItId()));
+
mpShadow = sidebarwindows::ShadowOverlayObject::CreateShadowOverlayObject( mrView );
if ( mpShadow )
{
@@ -502,6 +506,11 @@ tools::Time SwAnnotationWin::GetTime() const
return mpField->GetTime();
}
+FactoryFunction SwAnnotationWin::GetUITestFactory() const
+{
+ return CommentUIObject::create;
+}
+
} // end of namespace sw::annotation
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/uiobject.hxx b/sw/source/uibase/inc/uiobject.hxx
index 97362b51ae0f..944384a595e7 100644
--- a/sw/source/uibase/inc/uiobject.hxx
+++ b/sw/source/uibase/inc/uiobject.hxx
@@ -16,6 +16,8 @@
#include "edtwin.hxx"
#include "navipi.hxx"
+#include <AnnotationWin.hxx>
+
class SwEditWinUIObject : public WindowUIObject
{
public:
@@ -59,6 +61,27 @@ protected:
OUString get_name() const override;
};
+// This class handles the Comments as a UIObject to be used in UITest Framework
+class CommentUIObject : public WindowUIObject
+{
+ VclPtr<sw::annotation::SwAnnotationWin> mxCommentUIObject;
+
+public:
+
+ CommentUIObject(const VclPtr<sw::annotation::SwAnnotationWin>& xCommentUIObject);
+
+ virtual StringMap get_state() override;
+
+ virtual void execute(const OUString& rAction,
+ const StringMap& rParameters) override;
+
+ static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
+
+protected:
+
+ OUString get_name() const override;
+
+};
#endif
diff --git a/sw/source/uibase/uitest/uiobject.cxx b/sw/source/uibase/uitest/uiobject.cxx
index 7f922dc9ce16..85b261ea87b9 100644
--- a/sw/source/uibase/uitest/uiobject.cxx
+++ b/sw/source/uibase/uitest/uiobject.cxx
@@ -16,6 +16,11 @@
#include <sfx2/sidebar/Sidebar.hxx>
#include <sfx2/viewfrm.hxx>
+#include <AnnotationWin.hxx>
+#include <comphelper/string.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/editview.hxx>
+
SwEditWinUIObject::SwEditWinUIObject(const VclPtr<SwEditWin>& xEditWin):
WindowUIObject(xEditWin),
mxEditWin(xEditWin)
@@ -168,5 +173,75 @@ OUString SwNavigationPIUIObject::get_name() const
return "SwNavigationPIUIObject";
}
+CommentUIObject::CommentUIObject(const VclPtr<sw::annotation::SwAnnotationWin>& xCommentUIObject):
+ WindowUIObject(xCommentUIObject),
+ mxCommentUIObject(xCommentUIObject)
+{
+}
+
+StringMap CommentUIObject::get_state()
+{
+ StringMap aMap = WindowUIObject::get_state();
+ aMap["Author"] = mxCommentUIObject->GetAuthor();
+ aMap["ReadOnly"] = OUString::boolean(mxCommentUIObject->IsReadOnly());
+ aMap["Resolved"] = OUString::boolean(mxCommentUIObject->IsResolved());
+ aMap["Visible"] = OUString::boolean(mxCommentUIObject->IsVisible());
+
+ aMap["Text"] = mxCommentUIObject->GetOutliner()->GetEditEngine().GetText();
+ aMap["SelectedText"] = mxCommentUIObject->GetOutlinerView()->GetEditView().GetSelected();
+ return aMap;
+}
+
+void CommentUIObject::execute(const OUString& rAction,
+ const StringMap& rParameters)
+{
+ 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();
+ ESelection aNewSelection( 0 , nMin, mxCommentUIObject->GetOutliner()->GetParagraphCount()-1, nMax );
+ mxCommentUIObject->GetOutlinerView()->SetSelection( aNewSelection );
+ }
+ }
+ else if (rAction == "LEAVE")
+ {
+ mxCommentUIObject->SwitchToFieldPos();
+ }
+ else if (rAction == "HIDE")
+ {
+ mxCommentUIObject->HideNote();
+ }
+ else if (rAction == "SHOW")
+ {
+ mxCommentUIObject->ShowNote();
+ }
+ else if (rAction == "DELETE")
+ {
+ mxCommentUIObject->Delete();
+ }
+ else if (rAction == "RESOLVE")
+ {
+ mxCommentUIObject->SetResolved(true);
+ }
+ else
+ WindowUIObject::execute(rAction, rParameters);
+}
+
+std::unique_ptr<UIObject> CommentUIObject::create(vcl::Window* pWindow)
+{
+ sw::annotation::SwAnnotationWin* pCommentUIObject = dynamic_cast<sw::annotation::SwAnnotationWin*>(pWindow);
+ assert(pCommentUIObject);
+ return std::unique_ptr<UIObject>(new CommentUIObject(pCommentUIObject));
+}
+
+OUString CommentUIObject::get_name() const
+{
+ return "CommentUIObject";
+}
+
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */