10 #include <config_folders.h>
14 #include <rtl/bootstrap.hxx>
15 #include <rtl/ustrbuf.hxx>
16 #include <osl/file.hxx>
22 #include <com/sun/star/beans/PropertyValue.hpp>
30 if (nType == WindowType::DIALOG || nType == WindowType::MODELESSDIALOG)
34 if (nType >= WindowType::MESSBOX && nType <= WindowType::QUERYBOX)
37 if (nType == WindowType::TABDIALOG)
46 if (eType == WindowType::FLOATINGWINDOW)
55 if (isDialogWindow(pWindow) || isTopWindow(pWindow))
62 return get_top_parent(pParent);
69 static const char* pFile = std::getenv(
"LO_COLLECT_UIINFO");
72 OUString aDirPath(
"${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER
74 rtl::Bootstrap::expandMacros(aDirPath);
75 osl::Directory::createPath(aDirPath);
76 OUString aFilePath = aDirPath + OUString::fromUtf8(pFile);
78 maStream.
Open(aFilePath, StreamMode::READWRITE | StreamMode::TRUNC);
84 const css::uno::Sequence<css::beans::PropertyValue>& rArgs)
89 OUStringBuffer
aBuffer(rAction);
91 if (rArgs.hasElements())
94 for (
const css::beans::PropertyValue& rProp : rArgs)
96 OUString aTypeName = rProp.Value.getValueTypeName();
98 if (aTypeName ==
"long" || aTypeName ==
"short")
101 rProp.Value >>= nValue;
102 aBuffer.append(
"\"").append(rProp.Name).append(
"\": ");
103 aBuffer.append(OUString::number(nValue)).append(
", ");
105 else if (aTypeName ==
"unsigned long")
108 rProp.Value >>= nValue;
109 aBuffer.append(
"\"").append(rProp.Name).append(
"\": ");
110 aBuffer.append(OUString::number(nValue)).append(
", ");
112 else if (aTypeName ==
"boolean")
115 rProp.Value >>= bValue;
116 aBuffer.append(
"\"").append(rProp.Name).append(
"\": ");
118 aBuffer.append(
"True, ");
120 aBuffer.append(
"False, ");
126 OUString
aCommand(aBuffer.makeStringAndClear());
136 for (sal_Int32 i = 0;
i < nCount; ++
i)
155 if (xUIElement->
get_id().isEmpty())
159 OUString aAction = pUIObject->get_action(nEvent);
160 if (!xUIElement->
HasFocus() && !child_windows_have_focus(xUIElement))
165 if (!aAction.isEmpty())
174 if (xUIWin->
get_id().isEmpty())
178 OUString aAction = pUIObject->get_action(nEvent);
180 if (!aAction.isEmpty())
213 std::map<OUString, sal_uInt16> aKeyMap
221 for (
const auto& itr : aKeyMap)
223 if (itr.second == nKeyCode)
231 if (!aFound.isEmpty() || bShift || bMod1 || bMod2 || bMod3)
233 aKeyCode =
"{\"KEYCODE\": \"";
235 aKeyCode +=
"SHIFT+";
243 if (aFound.isEmpty())
244 aKeyCode += OUStringChar(nChar) +
"\"}";
246 aKeyCode += aFound +
"\"}";
250 aKeyCode =
"{\"TEXT\": \"" + OUStringChar(nChar) +
"\"}";
262 OUString aParentID = pParent->
get_id();
266 if (pUIObject->get_type() ==
"EditUIObject")
268 if (aParentID.isEmpty())
271 aParentID = pParent_top->
get_id();
273 if (aParentID.isEmpty())
275 aContent +=
"Type on '" + rID +
"' " + aKeyCode;
279 aContent +=
"Type on '" + rID +
"' " + aKeyCode +
" from " + aParentID;
282 else if (pUIObject->get_type() ==
"SwEditWinUIObject" && rID ==
"writer_edit")
284 aContent =
"Type on writer " + aKeyCode;
286 else if (pUIObject->get_type() ==
"ScGridWinUIObject" && rID ==
"grid_window")
288 aContent =
"Type on current cell " + aKeyCode;
290 else if (pUIObject->get_type() ==
"ImpressWindowUIObject" && rID ==
"impress_win")
292 aContent =
"Type on impress " + aKeyCode;
294 else if (pUIObject->get_type() ==
"WindowUIObject" && rID ==
"math_edit")
296 aContent =
"Type on math " + aKeyCode;
298 else if (rID ==
"draw_win")
300 aContent =
"Type on draw " + aKeyCode;
304 if (aParentID.isEmpty())
307 aParentID = pParent_top->
get_id();
309 if (aParentID.isEmpty())
311 aContent =
"Type on '" + rID +
"' " + aKeyCode;
315 aContent =
"Type on '" + rID +
"' " + aKeyCode +
" from " + aParentID;
323 OUString StringMapToOUString(
const std::map<OUString, OUString>& rParameters)
325 if (rParameters.empty())
328 OUStringBuffer aParameterString(static_cast<int>(rParameters.size() * 32));
329 aParameterString.append(
" {");
331 for (std::map<OUString, OUString>::const_iterator itr = rParameters.begin();
332 itr != rParameters.end(); ++itr)
334 if (itr != rParameters.begin())
335 aParameterString.append(
", ");
336 aParameterString.append(
"\"")
343 aParameterString.append(
"}");
345 return aParameterString.makeStringAndClear();
348 const OUString& GetValueInMapWithIndex(
const std::map<OUString, OUString>& rParameters,
353 std::map<OUString, OUString>::const_iterator itr = rParameters.begin();
355 for (; itr != rParameters.end() && j < index; ++itr, ++j)
358 assert(itr != rParameters.end());
363 const OUString& GetKeyInMapWithIndex(
const std::map<OUString, OUString>& rParameters,
368 std::map<OUString, OUString>::const_iterator itr = rParameters.begin();
370 for (; itr != rParameters.end() && j < index; ++itr, ++j)
373 assert(itr != rParameters.end());
381 OUString aParameterString = StringMapToOUString(rDescription.
aParameters);
386 if (rDescription.
aAction ==
"SET")
388 aLogLine =
"Set Zoom to " + GetValueInMapWithIndex(rDescription.
aParameters, 0);
390 else if (rDescription.
aAction ==
"SIDEBAR")
392 aLogLine =
"From SIDEBAR Choose " + aParameterString;
394 else if (rDescription.
aKeyWord ==
"ValueSet")
396 aLogLine =
"Choose element with position "
397 + GetValueInMapWithIndex(rDescription.
aParameters, 0) +
" in '"
398 + rDescription.
aID +
"' from '" + rDescription.
aParent +
"'";
400 else if (rDescription.
aAction ==
"SELECT" && rDescription.
aID.isEmpty())
402 aLogLine =
"Select " + aParameterString;
404 else if (rDescription.
aID ==
"writer_edit")
406 if (rDescription.
aAction ==
"GOTO")
408 aLogLine =
"GOTO page number " + GetValueInMapWithIndex(rDescription.
aParameters, 0);
410 else if (rDescription.
aAction ==
"SELECT")
412 OUString
to = GetValueInMapWithIndex(rDescription.
aParameters, 0);
414 aLogLine =
"Select from Pos " + from +
" to Pos " + to;
416 else if (rDescription.
aAction ==
"CREATE_TABLE")
419 aLogLine =
"Create Table with " + size;
422 else if (rDescription.
aAction ==
"COPY")
424 aLogLine =
"Copy the Selected Text";
426 else if (rDescription.
aAction ==
"CUT")
428 aLogLine =
"Cut the Selected Text";
430 else if (rDescription.
aAction ==
"PASTE")
432 aLogLine =
"Paste in the Current Cursor Location";
434 else if (rDescription.
aAction ==
"BREAK_PAGE")
436 aLogLine =
"Insert Break Page";
439 else if (rDescription.
aID ==
"grid_window")
441 if (rDescription.
aAction ==
"SELECT")
444 if (type ==
"CELL" || type ==
"RANGE")
446 aLogLine =
"Select from calc" + aParameterString;
448 else if (type ==
"TABLE")
450 aLogLine =
"Switch to sheet number "
451 + GetValueInMapWithIndex(rDescription.
aParameters, 0);
454 else if (rDescription.
aAction ==
"LAUNCH")
456 aLogLine =
"Launch" + GetKeyInMapWithIndex(rDescription.
aParameters, 2) +
" from Col "
457 + GetValueInMapWithIndex(rDescription.
aParameters, 2) +
" and Row "
458 + GetValueInMapWithIndex(rDescription.
aParameters, 1);
460 else if (rDescription.
aAction ==
"DELETE_CONTENT")
462 aLogLine =
"Remove Content from This " + aParameterString;
464 else if (rDescription.
aAction ==
"DELETE_CELLS")
466 aLogLine =
"Delete The Cells in" + aParameterString;
468 else if (rDescription.
aAction ==
"INSERT_CELLS")
470 aLogLine =
"Insert Cell around the " + aParameterString;
472 else if (rDescription.
aAction ==
"CUT")
474 aLogLine =
"CUT the selected " + aParameterString;
476 else if (rDescription.
aAction ==
"COPY")
478 aLogLine =
"COPY the selected " + aParameterString;
480 else if (rDescription.
aAction ==
"PASTE")
482 aLogLine =
"Paste in the " + aParameterString;
484 else if (rDescription.
aAction ==
"MERGE_CELLS")
486 aLogLine =
"Merge " + aParameterString;
488 else if (rDescription.
aAction ==
"UNMERGE_CELL")
490 aLogLine =
"Delete the merged " + aParameterString;
492 else if (rDescription.
aAction ==
"Rename_Sheet")
494 aLogLine =
"Rename The Selected Tab to \""
495 + GetValueInMapWithIndex(rDescription.
aParameters, 0) +
"\"";
497 else if (rDescription.
aAction ==
"InsertTab")
499 aLogLine =
"Insert New Tab ";
501 else if (rDescription.
aAction ==
"COMMENT")
506 aLogLine =
"Open Comment";
508 else if (type ==
"CLOSE")
510 aLogLine =
"Close Comment";
514 else if (rDescription.
aID ==
"impress_win_or_draw_win")
516 if (rDescription.
aAction ==
"Insert_New_Page_or_Slide")
520 aLogLine =
"Insert New Slide at Position "
521 + GetValueInMapWithIndex(rDescription.
aParameters, 0);
525 aLogLine =
"Insert New Page at Position "
526 + GetValueInMapWithIndex(rDescription.
aParameters, 0);
529 else if (rDescription.
aAction ==
"Delete_Slide_or_Page")
534 =
"Delete Slide number " + GetValueInMapWithIndex(rDescription.
aParameters, 0);
539 =
"Delete Page number " + GetValueInMapWithIndex(rDescription.
aParameters, 0);
542 else if (rDescription.
aAction ==
"Duplicate")
544 aLogLine =
"Duplicate The Selected Slide ";
546 else if (rDescription.
aAction ==
"RENAME")
550 aLogLine =
"Rename The Selected Slide from \""
551 + GetValueInMapWithIndex(rDescription.
aParameters, 1) +
"\" to \""
552 + GetValueInMapWithIndex(rDescription.
aParameters, 0) +
"\"";
556 aLogLine =
"Rename The Selected Page from \""
557 + GetValueInMapWithIndex(rDescription.
aParameters, 1) +
"\" to \""
558 + GetValueInMapWithIndex(rDescription.
aParameters, 0) +
"\"";
562 else if (rDescription.
aKeyWord ==
"SwEditWinUIObject")
564 if (rDescription.
aAction ==
"LEAVE")
566 aLogLine =
"Leave '" + rDescription.
aID +
"'";
568 else if (rDescription.
aAction ==
"SHOW")
570 aLogLine =
"Show '" + rDescription.
aID +
"'";
572 else if (rDescription.
aAction ==
"HIDE")
574 aLogLine =
"Hide '" + rDescription.
aID +
"'";
576 else if (rDescription.
aAction ==
"DELETE")
578 aLogLine =
"Delete '" + rDescription.
aID +
"'";
580 else if (rDescription.
aAction ==
"SETRESOLVED")
582 aLogLine =
"Resolve '" + rDescription.
aID +
"'";
585 else if (rDescription.
aParent ==
"element_selector")
587 aLogLine =
"Select element no " + rDescription.
aID +
" From " + rDescription.
aParent;
589 else if (rDescription.
aKeyWord ==
"MenuButton")
591 if (rDescription.
aAction ==
"OPENLIST")
593 aLogLine =
"Open List From " + rDescription.
aID;
595 else if (rDescription.
aAction ==
"CLOSELIST")
597 aLogLine =
"Close List From " + rDescription.
aID;
599 else if (rDescription.
aAction ==
"OPENFROMLIST")
601 aLogLine =
"Select item no " + GetValueInMapWithIndex(rDescription.
aParameters, 0)
602 +
" From List of " + rDescription.
aID;
605 else if (rDescription.
aKeyWord ==
"VerticalTab")
607 aLogLine =
"Choose Tab number " + GetValueInMapWithIndex(rDescription.
aParameters, 0)
608 +
" in '" + rDescription.
aID +
"' from " + rDescription.
aParent;
612 aLogLine = rDescription.
aKeyWord +
" Action:" + rDescription.
aAction +
" Id:"
613 + rDescription.
aID +
" Parent:" + rDescription.
aParent + aParameterString;
virtual FactoryFunction GetUITestFactory() const
void log(std::u16string_view rString)
sal_uInt16 GetCode() const
constexpr sal_uInt16 KEY_UP
void logAction(VclPtr< Control > const &xUIElement, VclEventId nEvent)
constexpr sal_uInt16 KEY_END
static UITestLogger & getInstance()
void logEvent(const EventDescription &rDescription)
const OUString & get_id() const
Get the ID of the window.
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
constexpr sal_uInt16 KEY_PAGEUP
const OUString & getAppName() const
WinBits const WB_SYSTEMFLOATWIN
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
void Open(const OUString &rFileName, StreamMode eOpenMode)
constexpr sal_uInt16 KEY_DOWN
ImplSVData * ImplGetSVData()
#define SAL_CONFIGFILE(name)
void logCommand(const OUString &rAction, const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
bool WriteLine(const OString &rStr)
constexpr sal_uInt16 KEY_HOME
void logKeyInput(VclPtr< vcl::Window > const &xUIElement, const KeyEvent &rEvent)
constexpr sal_uInt16 KEY_PAGEDOWN
vcl::Window * GetParent() const
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_RIGHT
sal_uInt16 GetChildCount() const
const vcl::KeyCode & GetKeyCode() const
std::unique_ptr< char[]> aBuffer
constexpr sal_uInt16 KEY_ESCAPE
ImplSVFrameData maFrameData
std::unique_ptr< UITestLogger > m_pUITestLogger
sal_Unicode GetCharCode() const
constexpr sal_uInt16 KEY_BACKSPACE
WindowType GetType() const
reference_type * get() const
Get the body.
constexpr sal_uInt16 KEY_DELETE
constexpr sal_uInt16 KEY_LEFT
std::map< OUString, OUString > aParameters
constexpr sal_uInt16 KEY_INSERT
constexpr sal_uInt16 KEY_TAB
vcl::Window * GetChild(sal_uInt16 nChild) const