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>
This commit is contained in:
Shiko 2020-06-12 17:58:05 +02:00 committed by Ahmed ElShreif
parent 2ef9f5c15b
commit 7570406803
4 changed files with 110 additions and 0 deletions

View file

@ -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;

View file

@ -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: */

View file

@ -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

View file

@ -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: */