Kaydet (Commit) 1a91d1a5 authored tarafından Saurav Chirania's avatar Saurav Chirania Kaydeden (comit) Markus Mohrhard

uitest logger: support for buttons, dialog, command and key logging

This patch adds logging faclity for radiobuttons, checkboxes
and button clicks. It modifies the logging for UNO commands
and dialogs execution for consistency with other log
statements. It also makes key logging more informative
by printing the details of the object on which the user is
typing.

Change-Id: I911d0dfb64dacfde64193f0aea21f7d837dbf9da
Reviewed-on: https://gerrit.libreoffice.org/54745Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 565340d4
...@@ -148,6 +148,8 @@ public: ...@@ -148,6 +148,8 @@ public:
static std::unique_ptr<UIObject> create(vcl::Window* pWindow); static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
virtual OUString get_action(VclEventId nEvent) const override;
protected: protected:
virtual OUString get_name() const override; virtual OUString get_name() const override;
...@@ -230,6 +232,8 @@ public: ...@@ -230,6 +232,8 @@ public:
static std::unique_ptr<UIObject> create(vcl::Window* pWindow); static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
virtual OUString get_action(VclEventId nEvent) const override;
protected: protected:
virtual OUString get_name() const override; virtual OUString get_name() const override;
...@@ -251,6 +255,8 @@ public: ...@@ -251,6 +255,8 @@ public:
static std::unique_ptr<UIObject> create(vcl::Window* pWindow); static std::unique_ptr<UIObject> create(vcl::Window* pWindow);
virtual OUString get_action(VclEventId nEvent) const override;
protected: protected:
virtual OUString get_name() const override; virtual OUString get_name() const override;
......
...@@ -600,7 +600,7 @@ void collectUIInformation(const util::URL& rURL) ...@@ -600,7 +600,7 @@ void collectUIInformation(const util::URL& rURL)
if (!pFile) if (!pFile)
return; return;
UITestLogger::getInstance().logCommand(rURL.Complete); UITestLogger::getInstance().logCommand("CommandSent Name:" + rURL.Complete);
} }
} }
......
...@@ -157,7 +157,10 @@ void UITestLogger::logKeyInput(VclPtr<vcl::Window> const & xUIElement, const Key ...@@ -157,7 +157,10 @@ void UITestLogger::logKeyInput(VclPtr<vcl::Window> const & xUIElement, const Key
aKeyCode = "{\"TEXT\": \"" + OUStringLiteral1(nChar) + "\"}"; aKeyCode = "{\"TEXT\": \"" + OUStringLiteral1(nChar) + "\"}";
} }
OUString aContent = "Action on element: " + rID + " with action: TYPE and content: " + aKeyCode; std::unique_ptr<UIObject> pUIObject = xUIElement->GetUITestFactory()(xUIElement.get());
OUString aContent = pUIObject->get_type() + " Action:TYPE Id:" +
rID + " Parent: UNKNOWN "+ aKeyCode;
maStream.WriteLine(OUStringToOString(aContent, RTL_TEXTENCODING_UTF8)); maStream.WriteLine(OUStringToOString(aContent, RTL_TEXTENCODING_UTF8));
} }
......
...@@ -563,6 +563,17 @@ OUString ButtonUIObject::get_name() const ...@@ -563,6 +563,17 @@ OUString ButtonUIObject::get_name() const
return OUString("ButtonUIObject"); return OUString("ButtonUIObject");
} }
OUString ButtonUIObject::get_action(VclEventId nEvent) const
{
if (nEvent == VclEventId::ButtonClick)
{
return this->get_type() + " Action:CLICK Id:" + mxButton->get_id() + " Parent:" +
get_top_parent(mxButton)->get_id();
}
else
return WindowUIObject::get_action(nEvent);
}
std::unique_ptr<UIObject> ButtonUIObject::create(vcl::Window* pWindow) std::unique_ptr<UIObject> ButtonUIObject::create(vcl::Window* pWindow)
{ {
Button* pButton = dynamic_cast<Button*>(pWindow); Button* pButton = dynamic_cast<Button*>(pWindow);
...@@ -773,6 +784,17 @@ OUString CheckBoxUIObject::get_name() const ...@@ -773,6 +784,17 @@ OUString CheckBoxUIObject::get_name() const
return OUString("CheckBoxUIObject"); return OUString("CheckBoxUIObject");
} }
OUString CheckBoxUIObject::get_action(VclEventId nEvent) const
{
if (nEvent == VclEventId::CheckboxToggle)
{
return this->get_type() + " Action:CLICK Id:" + mxCheckBox->get_id() + " Parent:" +
get_top_parent(mxCheckBox)->get_id();
}
else
return WindowUIObject::get_action(nEvent);
}
std::unique_ptr<UIObject> CheckBoxUIObject::create(vcl::Window* pWindow) std::unique_ptr<UIObject> CheckBoxUIObject::create(vcl::Window* pWindow)
{ {
CheckBox* pCheckBox = dynamic_cast<CheckBox*>(pWindow); CheckBox* pCheckBox = dynamic_cast<CheckBox*>(pWindow);
...@@ -812,6 +834,17 @@ OUString RadioButtonUIObject::get_name() const ...@@ -812,6 +834,17 @@ OUString RadioButtonUIObject::get_name() const
return OUString("RadioButtonUIObject"); return OUString("RadioButtonUIObject");
} }
OUString RadioButtonUIObject::get_action(VclEventId nEvent) const
{
if (nEvent == VclEventId::RadiobuttonToggle)
{
return this->get_type() + " Action:CLICK Id:" + mxRadioButton->get_id() + " Parent:" +
get_top_parent(mxRadioButton)->get_id();
}
else
return WindowUIObject::get_action(nEvent);
}
std::unique_ptr<UIObject> RadioButtonUIObject::create(vcl::Window* pWindow) std::unique_ptr<UIObject> RadioButtonUIObject::create(vcl::Window* pWindow)
{ {
RadioButton* pRadioButton = dynamic_cast<RadioButton*>(pWindow); RadioButton* pRadioButton = dynamic_cast<RadioButton*>(pWindow);
......
...@@ -905,7 +905,7 @@ bool Dialog::ImplStartExecuteModal() ...@@ -905,7 +905,7 @@ bool Dialog::ImplStartExecuteModal()
css::document::DocumentEvent aObject; css::document::DocumentEvent aObject;
aObject.EventName = "DialogExecute"; aObject.EventName = "DialogExecute";
xEventBroadcaster->documentEventOccured(aObject); xEventBroadcaster->documentEventOccured(aObject);
UITestLogger::getInstance().log("DialogExecute"); UITestLogger::getInstance().log("ModalDialogExecuted Id:" + get_id());
if (comphelper::LibreOfficeKit::isActive()) if (comphelper::LibreOfficeKit::isActive())
{ {
...@@ -1444,6 +1444,7 @@ VclBuilderContainer::~VclBuilderContainer() ...@@ -1444,6 +1444,7 @@ VclBuilderContainer::~VclBuilderContainer()
ModelessDialog::ModelessDialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, InitFlag eFlag) ModelessDialog::ModelessDialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, InitFlag eFlag)
: Dialog(pParent, rID, rUIXMLDescription, WindowType::MODELESSDIALOG, eFlag) : Dialog(pParent, rID, rUIXMLDescription, WindowType::MODELESSDIALOG, eFlag)
{ {
UITestLogger::getInstance().log("ModelessDialogConstructed Id:" + get_id());
} }
ModalDialog::ModalDialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, bool bBorder ) : ModalDialog::ModalDialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, bool bBorder ) :
...@@ -1459,7 +1460,6 @@ void ModelessDialog::Activate() ...@@ -1459,7 +1460,6 @@ void ModelessDialog::Activate()
css::document::DocumentEvent aObject; css::document::DocumentEvent aObject;
aObject.EventName = "ModelessDialogVisible"; aObject.EventName = "ModelessDialogVisible";
xEventBroadcaster->documentEventOccured(aObject); xEventBroadcaster->documentEventOccured(aObject);
UITestLogger::getInstance().log("Modeless Dialog Visible");
Dialog::Activate(); Dialog::Activate();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment