summaryrefslogtreecommitdiff
path: root/vcl/source/uitest/logger.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source/uitest/logger.cxx')
-rw-r--r--vcl/source/uitest/logger.cxx344
1 files changed, 195 insertions, 149 deletions
diff --git a/vcl/source/uitest/logger.cxx b/vcl/source/uitest/logger.cxx
index 0ecd673f9879..03c439fcbd7c 100644
--- a/vcl/source/uitest/logger.cxx
+++ b/vcl/source/uitest/logger.cxx
@@ -20,9 +20,9 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <memory>
-namespace{
-
-bool isDialogWindow(vcl::Window const * pWindow)
+namespace
+{
+bool isDialogWindow(vcl::Window const* pWindow)
{
WindowType nType = pWindow->GetType();
// DIALOG to MODALDIALOG
@@ -39,7 +39,7 @@ bool isDialogWindow(vcl::Window const * pWindow)
return false;
}
-bool isTopWindow(vcl::Window const * pWindow)
+bool isTopWindow(vcl::Window const* pWindow)
{
WindowType eType = pWindow->GetType();
if (eType == WindowType::FLOATINGWINDOW)
@@ -60,17 +60,16 @@ vcl::Window* get_top_parent(vcl::Window* pWindow)
return get_top_parent(pParent);
}
-
-
}
-UITestLogger::UITestLogger():
- maStream(),
- mbValid(false)
+UITestLogger::UITestLogger()
+ : maStream()
+ , mbValid(false)
{
static const char* pFile = std::getenv("LO_COLLECT_UIINFO");
if (pFile)
{
- OUString aDirPath("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/uitest/");
+ OUString aDirPath("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER
+ "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/uitest/");
rtl::Bootstrap::expandMacros(aDirPath);
osl::Directory::createPath(aDirPath);
OUString aFilePath = aDirPath + OUString::fromUtf8(pFile);
@@ -80,7 +79,8 @@ UITestLogger::UITestLogger():
}
}
-void UITestLogger::logCommand(const OUString& rAction, const css::uno::Sequence< css::beans::PropertyValue >& rArgs)
+void UITestLogger::logCommand(const OUString& rAction,
+ const css::uno::Sequence<css::beans::PropertyValue>& rArgs)
{
if (!mbValid)
return;
@@ -126,10 +126,10 @@ void UITestLogger::logCommand(const OUString& rAction, const css::uno::Sequence<
maStream.WriteLine(OUStringToOString(aCommand, RTL_TEXTENCODING_UTF8));
}
-namespace {
-
+namespace
+{
// most likely this should be recursive
-bool child_windows_have_focus(VclPtr<vcl::Window> const & xUIElement)
+bool child_windows_have_focus(VclPtr<vcl::Window> const& xUIElement)
{
sal_Int32 nCount = xUIElement->GetChildCount();
for (sal_Int32 i = 0; i < nCount; ++i)
@@ -144,10 +144,9 @@ bool child_windows_have_focus(VclPtr<vcl::Window> const & xUIElement)
}
return false;
}
-
}
-void UITestLogger::logAction(VclPtr<Control> const & xUIElement, VclEventId nEvent)
+void UITestLogger::logAction(VclPtr<Control> const& xUIElement, VclEventId nEvent)
{
if (!mbValid)
return;
@@ -177,14 +176,14 @@ void UITestLogger::log(const OUString& rString)
maStream.WriteLine(OUStringToOString(rString, RTL_TEXTENCODING_UTF8));
}
-void UITestLogger::logKeyInput(VclPtr<vcl::Window> const & xUIElement, const KeyEvent& rEvent)
+void UITestLogger::logKeyInput(VclPtr<vcl::Window> const& xUIElement, const KeyEvent& rEvent)
{
if (!mbValid)
return;
//We need to check for Parent's ID in case the UI Element is SubEdit of Combobox/SpinField
- const OUString& rID = xUIElement->get_id().isEmpty() ?
- xUIElement->GetParent()->get_id() : xUIElement->get_id();
+ const OUString& rID
+ = xUIElement->get_id().isEmpty() ? xUIElement->GetParent()->get_id() : xUIElement->get_id();
if (rID.isEmpty())
return;
@@ -195,22 +194,12 @@ void UITestLogger::logKeyInput(VclPtr<vcl::Window> const & xUIElement, const Key
bool bMod2 = rEvent.GetKeyCode().IsMod2();
bool bMod3 = rEvent.GetKeyCode().IsMod3();
- std::map<OUString, sal_uInt16> aKeyMap = {
- {"ESC", KEY_ESCAPE},
- {"TAB", KEY_TAB},
- {"DOWN", KEY_DOWN},
- {"UP", KEY_UP},
- {"LEFT", KEY_LEFT},
- {"RIGHT", KEY_RIGHT},
- {"DELETE", KEY_DELETE},
- {"INSERT", KEY_INSERT},
- {"BACKSPACE", KEY_BACKSPACE},
- {"RETURN", KEY_RETURN},
- {"HOME", KEY_HOME},
- {"END", KEY_END},
- {"PAGEUP", KEY_PAGEUP},
- {"PAGEDOWN", KEY_PAGEDOWN}
- };
+ std::map<OUString, sal_uInt16> aKeyMap
+ = { { "ESC", KEY_ESCAPE }, { "TAB", KEY_TAB }, { "DOWN", KEY_DOWN },
+ { "UP", KEY_UP }, { "LEFT", KEY_LEFT }, { "RIGHT", KEY_RIGHT },
+ { "DELETE", KEY_DELETE }, { "INSERT", KEY_INSERT }, { "BACKSPACE", KEY_BACKSPACE },
+ { "RETURN", KEY_RETURN }, { "HOME", KEY_HOME }, { "END", KEY_END },
+ { "PAGEUP", KEY_PAGEUP }, { "PAGEDOWN", KEY_PAGEDOWN } };
OUString aFound;
for (auto& itr : aKeyMap)
@@ -247,7 +236,7 @@ void UITestLogger::logKeyInput(VclPtr<vcl::Window> const & xUIElement, const Key
std::unique_ptr<UIObject> pUIObject = xUIElement->GetUITestFactory()(xUIElement.get());
- VclPtr <vcl::Window> pParent = xUIElement->GetParent();
+ VclPtr<vcl::Window> pParent = xUIElement->GetParent();
while (!pParent->IsTopWindow())
{
@@ -258,52 +247,63 @@ void UITestLogger::logKeyInput(VclPtr<vcl::Window> const & xUIElement, const Key
OUString aContent;
- if(pUIObject->get_type()=="EditUIObject"){
- if(aParentID=="")
+ if (pUIObject->get_type() == "EditUIObject")
+ {
+ if (aParentID.isEmpty())
{
- VclPtr <vcl::Window> pParent_top = get_top_parent(xUIElement);
- aParentID= pParent_top->get_id();
+ VclPtr<vcl::Window> pParent_top = get_top_parent(xUIElement);
+ aParentID = pParent_top->get_id();
}
- if(aParentID==""){
- aContent = aContent+"Type on '" + rID + "' " + aKeyCode;
+ if (aParentID.isEmpty())
+ {
+ aContent = aContent + "Type on '" + rID + "' " + aKeyCode;
}
- else{
- aContent = aContent+"Type on '" + rID + "' " + aKeyCode + " from " + aParentID ;
+ else
+ {
+ aContent = aContent + "Type on '" + rID + "' " + aKeyCode + " from " + aParentID;
}
}
- else if(pUIObject->get_type()=="SwEditWinUIObject" && rID=="writer_edit"){
- aContent = "Type on writer " + aKeyCode ;
+ else if (pUIObject->get_type() == "SwEditWinUIObject" && rID == "writer_edit")
+ {
+ aContent = "Type on writer " + aKeyCode;
}
- else if(pUIObject->get_type()=="ScGridWinUIObject" && rID=="grid_window"){
- aContent = "Type on current cell " + aKeyCode ;
+ else if (pUIObject->get_type() == "ScGridWinUIObject" && rID == "grid_window")
+ {
+ aContent = "Type on current cell " + aKeyCode;
}
- else if(pUIObject->get_type()=="ImpressWindowUIObject" && rID=="impress_win"){
- aContent = "Type on impress " + aKeyCode ;
+ else if (pUIObject->get_type() == "ImpressWindowUIObject" && rID == "impress_win")
+ {
+ aContent = "Type on impress " + aKeyCode;
}
- else if(pUIObject->get_type()=="WindowUIObject" && rID=="math_edit"){
- aContent = "Type on math " + aKeyCode ;
+ else if (pUIObject->get_type() == "WindowUIObject" && rID == "math_edit")
+ {
+ aContent = "Type on math " + aKeyCode;
}
- else if(rID=="draw_win"){
- aContent = "Type on draw " + aKeyCode ;
+ else if (rID == "draw_win")
+ {
+ aContent = "Type on draw " + aKeyCode;
}
- else{
- if(aParentID=="")
+ else
+ {
+ if (aParentID.isEmpty())
{
- VclPtr <vcl::Window> pParent_top = get_top_parent(xUIElement);
- aParentID= pParent_top->get_id();
+ VclPtr<vcl::Window> pParent_top = get_top_parent(xUIElement);
+ aParentID = pParent_top->get_id();
}
- if(aParentID==""){
- aContent = "Type on '" + rID + "' " + aKeyCode ;
+ if (aParentID.isEmpty())
+ {
+ aContent = "Type on '" + rID + "' " + aKeyCode;
}
- else{
- aContent = "Type on '" + rID + "' " + aKeyCode + " from " + aParentID ;
+ else
+ {
+ aContent = "Type on '" + rID + "' " + aKeyCode + " from " + aParentID;
}
}
maStream.WriteLine(OUStringToOString(aContent, RTL_TEXTENCODING_UTF8));
}
-namespace {
-
+namespace
+{
OUString StringMapToOUString(const std::map<OUString, OUString>& rParameters)
{
if (rParameters.empty())
@@ -312,11 +312,15 @@ OUString StringMapToOUString(const std::map<OUString, OUString>& rParameters)
OUStringBuffer aParameterString = " {";
for (std::map<OUString, OUString>::const_iterator itr = rParameters.begin();
- itr != rParameters.end(); ++itr)
+ itr != rParameters.end(); ++itr)
{
if (itr != rParameters.begin())
aParameterString.append(", ");
- aParameterString.append("\"").append(itr->first).append("\": \"").append(itr->second).append("\"");
+ aParameterString.append("\"")
+ .append(itr->first)
+ .append("\": \"")
+ .append(itr->second)
+ .append("\"");
}
aParameterString.append("}");
@@ -324,29 +328,29 @@ OUString StringMapToOUString(const std::map<OUString, OUString>& rParameters)
return aParameterString.makeStringAndClear();
}
-OUString GetValueInMapWithIndex(const std::map<OUString, OUString>& rParameters,sal_Int32 index)
+OUString GetValueInMapWithIndex(const std::map<OUString, OUString>& rParameters, sal_Int32 index)
{
- sal_Int32 j=0;
+ sal_Int32 j = 0;
std::map<OUString, OUString>::const_iterator itr = rParameters.begin();
- for ( ; itr != rParameters.end() && j<index ; ++itr,++j);
+ for (; itr != rParameters.end() && j < index; ++itr, ++j)
+ ;
return itr->second;
}
-
-OUString GetKeyInMapWithIndex(const std::map<OUString, OUString>& rParameters,sal_Int32 index)
+OUString GetKeyInMapWithIndex(const std::map<OUString, OUString>& rParameters, sal_Int32 index)
{
- sal_Int32 j=0;
+ sal_Int32 j = 0;
std::map<OUString, OUString>::const_iterator itr = rParameters.begin();
- for ( ; itr != rParameters.end() && j<index ; ++itr,++j);
+ for (; itr != rParameters.end() && j < index; ++itr, ++j)
+ ;
return itr->first;
}
-
}
void UITestLogger::logEvent(const EventDescription& rDescription)
@@ -354,138 +358,181 @@ void UITestLogger::logEvent(const EventDescription& rDescription)
OUString aParameterString = StringMapToOUString(rDescription.aParameters);
//here we will customize our statments depending on the caller of this function
- OUString aLogLine ;
+ OUString aLogLine;
//first check on general commands
- if(rDescription.aAction=="SET"){
- aLogLine = "Set Zoom to " + GetValueInMapWithIndex(rDescription.aParameters,0);
+ if (rDescription.aAction == "SET")
+ {
+ aLogLine = "Set Zoom to " + GetValueInMapWithIndex(rDescription.aParameters, 0);
}
- else if(rDescription.aAction=="SIDEBAR"){
+ else if (rDescription.aAction == "SIDEBAR")
+ {
aLogLine = "From SIDEBAR Choose " + aParameterString;
}
- else if(rDescription.aAction=="SELECT" && rDescription.aID==""){
+ else if (rDescription.aAction == "SELECT" && rDescription.aID.isEmpty())
+ {
aLogLine = "Select " + aParameterString;
}
- else if(rDescription.aID=="writer_edit"){
- if(rDescription.aAction=="GOTO"){
- aLogLine = "GOTO page number " + GetValueInMapWithIndex(rDescription.aParameters,0);
+ else if (rDescription.aID == "writer_edit")
+ {
+ if (rDescription.aAction == "GOTO")
+ {
+ aLogLine = "GOTO page number " + GetValueInMapWithIndex(rDescription.aParameters, 0);
}
- else if(rDescription.aAction=="SELECT"){
- OUString to = GetValueInMapWithIndex(rDescription.aParameters,0);
- OUString from = GetValueInMapWithIndex(rDescription.aParameters,1);
- aLogLine = "Select from Pos " + from + " to Pos " + to ;
+ else if (rDescription.aAction == "SELECT")
+ {
+ OUString to = GetValueInMapWithIndex(rDescription.aParameters, 0);
+ OUString from = GetValueInMapWithIndex(rDescription.aParameters, 1);
+ aLogLine = "Select from Pos " + from + " to Pos " + to;
}
- else if(rDescription.aAction=="CREATE_TABLE"){
- OUString size = GetValueInMapWithIndex(rDescription.aParameters,0);
- aLogLine = "Create Table with " + size; ;
+ else if (rDescription.aAction == "CREATE_TABLE")
+ {
+ OUString size = GetValueInMapWithIndex(rDescription.aParameters, 0);
+ aLogLine = "Create Table with " + size;
+ ;
}
- else if(rDescription.aAction=="COPY"){
- aLogLine = "Copy the Selected Text";
+ else if (rDescription.aAction == "COPY")
+ {
+ aLogLine = "Copy the Selected Text";
}
- else if(rDescription.aAction=="CUT"){
- aLogLine = "Cut the Selected Text";
+ else if (rDescription.aAction == "CUT")
+ {
+ aLogLine = "Cut the Selected Text";
}
- else if(rDescription.aAction=="PASTE"){
- aLogLine = "Paste in the Current Cursor Location";
+ else if (rDescription.aAction == "PASTE")
+ {
+ aLogLine = "Paste in the Current Cursor Location";
}
- else if(rDescription.aAction=="BREAK_PAGE"){
- aLogLine = "Insert Break Page";
+ else if (rDescription.aAction == "BREAK_PAGE")
+ {
+ aLogLine = "Insert Break Page";
}
}
- else if(rDescription.aID=="grid_window"){
-
- if(rDescription.aAction=="SELECT"){
- OUString type = GetKeyInMapWithIndex(rDescription.aParameters,0);
- if(type=="CELL" || type=="RANGE"){
- aLogLine = "Select from calc" + aParameterString ;
+ else if (rDescription.aID == "grid_window")
+ {
+ if (rDescription.aAction == "SELECT")
+ {
+ OUString type = GetKeyInMapWithIndex(rDescription.aParameters, 0);
+ if (type == "CELL" || type == "RANGE")
+ {
+ aLogLine = "Select from calc" + aParameterString;
}
- else if(type=="TABLE")
+ else if (type == "TABLE")
{
- aLogLine = "Switch to sheet number " + GetValueInMapWithIndex(rDescription.aParameters,0) ;
+ aLogLine = "Switch to sheet number "
+ + GetValueInMapWithIndex(rDescription.aParameters, 0);
}
}
- else if(rDescription.aAction=="LAUNCH"){
- aLogLine = "Lanuch AutoFilter from Col "+
- GetValueInMapWithIndex(rDescription.aParameters,2) +
- " and Row " + GetValueInMapWithIndex(rDescription.aParameters,1);
+ else if (rDescription.aAction == "LAUNCH")
+ {
+ aLogLine = "Lanuch AutoFilter from Col "
+ + GetValueInMapWithIndex(rDescription.aParameters, 2) + " and Row "
+ + GetValueInMapWithIndex(rDescription.aParameters, 1);
}
- else if(rDescription.aAction=="DELETE_CONTENT"){
+ else if (rDescription.aAction == "DELETE_CONTENT")
+ {
aLogLine = "Remove Content from This " + aParameterString;
}
- else if(rDescription.aAction=="DELETE_CELLS"){
+ else if (rDescription.aAction == "DELETE_CELLS")
+ {
aLogLine = "Delete The Cells in" + aParameterString;
}
- else if(rDescription.aAction=="INSERT_CELLS"){
+ else if (rDescription.aAction == "INSERT_CELLS")
+ {
aLogLine = "Insert Cell around the " + aParameterString;
}
- else if(rDescription.aAction=="CUT"){
+ else if (rDescription.aAction == "CUT")
+ {
aLogLine = "CUT the selected " + aParameterString;
}
- else if(rDescription.aAction=="COPY"){
+ else if (rDescription.aAction == "COPY")
+ {
aLogLine = "COPY the selected " + aParameterString;
}
- else if(rDescription.aAction=="PASTE"){
+ else if (rDescription.aAction == "PASTE")
+ {
aLogLine = "Paste in the " + aParameterString;
}
- else if(rDescription.aAction=="MERGE_CELLS"){
+ else if (rDescription.aAction == "MERGE_CELLS")
+ {
aLogLine = "Merge " + aParameterString;
}
- else if(rDescription.aAction=="UNMERGE_CELL"){
+ else if (rDescription.aAction == "UNMERGE_CELL")
+ {
aLogLine = "Delete the merged " + aParameterString;
}
- else if(rDescription.aAction=="Rename_Sheet"){
- aLogLine = "Rename The Selected Tab to \""+\
- GetValueInMapWithIndex(rDescription.aParameters,0)+"\"";
+ else if (rDescription.aAction == "Rename_Sheet")
+ {
+ aLogLine = "Rename The Selected Tab to \""
+ + GetValueInMapWithIndex(rDescription.aParameters, 0) + "\"";
}
- else if(rDescription.aAction=="InsertTab"){
+ else if (rDescription.aAction == "InsertTab")
+ {
aLogLine = "Insert New Tab ";
}
}
- else if(rDescription.aID=="impress_win_or_draw_win"){
- if(rDescription.aAction=="Insert_New_Page_or_Slide"){
- if(UITestLogger::getInstance().getAppName()=="impress"){
- aLogLine = "Insert New Slide at Position " + GetValueInMapWithIndex(rDescription.aParameters,0);
+ else if (rDescription.aID == "impress_win_or_draw_win")
+ {
+ if (rDescription.aAction == "Insert_New_Page_or_Slide")
+ {
+ if (UITestLogger::getInstance().getAppName() == "impress")
+ {
+ aLogLine = "Insert New Slide at Position "
+ + GetValueInMapWithIndex(rDescription.aParameters, 0);
}
- else if(UITestLogger::getInstance().getAppName()=="draw"){
- aLogLine = "Insert New Page at Position " + GetValueInMapWithIndex(rDescription.aParameters,0);
+ else if (UITestLogger::getInstance().getAppName() == "draw")
+ {
+ aLogLine = "Insert New Page at Position "
+ + GetValueInMapWithIndex(rDescription.aParameters, 0);
}
}
- else if(rDescription.aAction=="Delete_Slide_or_Page"){
- if(UITestLogger::getInstance().getAppName()=="impress"){
- aLogLine = "Delete Slide number "+ GetValueInMapWithIndex(rDescription.aParameters,0);
+ else if (rDescription.aAction == "Delete_Slide_or_Page")
+ {
+ if (UITestLogger::getInstance().getAppName() == "impress")
+ {
+ aLogLine
+ = "Delete Slide number " + GetValueInMapWithIndex(rDescription.aParameters, 0);
}
- else if(UITestLogger::getInstance().getAppName()=="draw"){
- aLogLine = "Delete Page number "+ GetValueInMapWithIndex(rDescription.aParameters,0);
+ else if (UITestLogger::getInstance().getAppName() == "draw")
+ {
+ aLogLine
+ = "Delete Page number " + GetValueInMapWithIndex(rDescription.aParameters, 0);
}
}
- else if(rDescription.aAction=="Duplicate"){
+ else if (rDescription.aAction == "Duplicate")
+ {
aLogLine = "Duplicate The Selected Slide ";
}
- else if(rDescription.aAction=="RENAME"){
- if(UITestLogger::getInstance().getAppName()=="impress"){
- aLogLine = "Rename The Selected Slide from \""+ GetValueInMapWithIndex(rDescription.aParameters,1)+\
- "\" to \"" + GetValueInMapWithIndex(rDescription.aParameters,0)+"\"";
+ else if (rDescription.aAction == "RENAME")
+ {
+ if (UITestLogger::getInstance().getAppName() == "impress")
+ {
+ aLogLine = "Rename The Selected Slide from \""
+ + GetValueInMapWithIndex(rDescription.aParameters, 1) + "\" to \""
+ + GetValueInMapWithIndex(rDescription.aParameters, 0) + "\"";
}
- else if(UITestLogger::getInstance().getAppName()=="draw"){
- aLogLine = "Rename The Selected Page from \""+ GetValueInMapWithIndex(rDescription.aParameters,1)+\
- "\" to \"" + GetValueInMapWithIndex(rDescription.aParameters,0)+"\"";
+ else if (UITestLogger::getInstance().getAppName() == "draw")
+ {
+ aLogLine = "Rename The Selected Page from \""
+ + GetValueInMapWithIndex(rDescription.aParameters, 1) + "\" to \""
+ + GetValueInMapWithIndex(rDescription.aParameters, 0) + "\"";
}
}
}
- else if(rDescription.aParent=="element_selector"){
- aLogLine ="Select element no " + rDescription.aID +
- " From " + rDescription.aParent;
+ else if (rDescription.aParent == "element_selector")
+ {
+ aLogLine = "Select element no " + rDescription.aID + " From " + rDescription.aParent;
}
- else{
- aLogLine = rDescription.aKeyWord + " Action:" +
- rDescription.aAction + " Id:" + rDescription.aID +
- " Parent:" + rDescription.aParent + aParameterString;
+ else
+ {
+ aLogLine = rDescription.aKeyWord + " Action:" + rDescription.aAction + " Id:"
+ + rDescription.aID + " Parent:" + rDescription.aParent + aParameterString;
}
log(aLogLine);
}
UITestLogger& UITestLogger::getInstance()
{
- ImplSVData *const pSVData = ImplGetSVData();
+ ImplSVData* const pSVData = ImplGetSVData();
assert(pSVData);
if (!pSVData->maWinData.m_pUITestLogger)
@@ -496,5 +543,4 @@ UITestLogger& UITestLogger::getInstance()
return *pSVData->maWinData.m_pUITestLogger;
}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */