diff options
author | Saurav Chirania <saurav.chir@gmail.com> | 2018-07-13 01:13:11 +0530 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2018-07-31 00:35:42 +0200 |
commit | 7e65a0794b7c57210779bb9a6d1f2b2e49eb86e9 (patch) | |
tree | b15fe5aa2c79b8c1f1cbba28b1be2acbde025ce0 /vcl | |
parent | 051399740e41c6495ed362e78c63e0868bcd180c (diff) |
uitest logger: log more events
Logging for the following:
1) Object Selection
2) Sidebar / Deck opening
3) Parameters of UNO commands
4) Element Selection (Math)
5) Set Zoom (Impress)
6) Calc -
a) Autofilter Launch
b) Select Cell / Range of cells
c) Switch table
7) Writer -
a) Goto page
b) Set Zoom
Change-Id: Ifc7f603f62d10cfd1062923ded68203e574aebb6
Reviewed-on: https://gerrit.libreoffice.org/57368
Tested-by: Jenkins
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/uitest/logger.cxx | 81 |
1 files changed, 79 insertions, 2 deletions
diff --git a/vcl/source/uitest/logger.cxx b/vcl/source/uitest/logger.cxx index 54ac483ed627..be2648ead428 100644 --- a/vcl/source/uitest/logger.cxx +++ b/vcl/source/uitest/logger.cxx @@ -14,6 +14,7 @@ #include <rtl/bootstrap.hxx> #include <osl/file.hxx> #include <vcl/uitest/uiobject.hxx> +#include <vcl/uitest/eventdescription.hxx> #include <svdata.hxx> #include <memory> @@ -35,12 +36,53 @@ UITestLogger::UITestLogger(): } } -void UITestLogger::logCommand(const OUString& rAction) +void UITestLogger::logCommand(const OUString& rAction, const css::uno::Sequence< css::beans::PropertyValue >& rArgs) { if (!mbValid) return; - maStream.WriteLine(OUStringToOString(rAction, RTL_TEXTENCODING_UTF8)); + OUStringBuffer aBuffer(rAction); + sal_Int32 nCount = rArgs.getLength(); + + if (nCount > 0) + { + aBuffer.append(" {"); + for (sal_Int32 n = 0; n < nCount; n++) + { + const css::beans::PropertyValue& rProp = rArgs[n]; + + OUString aTypeName = rProp.Value.getValueTypeName(); + + if (aTypeName == "long" || aTypeName == "short") + { + sal_Int32 nValue = 0; + rProp.Value >>= nValue; + aBuffer.append("\"" + rProp.Name + "\": "); + aBuffer.append(OUString::number(nValue) + ", "); + } + else if (aTypeName == "unsigned long") + { + sal_uInt32 nValue = 0; + rProp.Value >>= nValue; + aBuffer.append("\"" + rProp.Name + "\": "); + aBuffer.append(OUString::number(nValue) + ", "); + } + else if (aTypeName == "boolean") + { + bool bValue = false; + rProp.Value >>= bValue; + aBuffer.append("\"" + rProp.Name + "\": "); + if (bValue) + aBuffer.append("True, "); + else + aBuffer.append("False, "); + } + } + aBuffer.append("}"); + } + + OUString aCommand(aBuffer.makeStringAndClear()); + maStream.WriteLine(OUStringToOString(aCommand, RTL_TEXTENCODING_UTF8)); } namespace { @@ -175,6 +217,41 @@ void UITestLogger::logKeyInput(VclPtr<vcl::Window> const & xUIElement, const Key maStream.WriteLine(OUStringToOString(aContent, RTL_TEXTENCODING_UTF8)); } +namespace { + +OUString StringMapToOUString(const std::map<OUString, OUString>& rParameters) +{ + if (rParameters.empty()) + return OUString(""); + + OUStringBuffer aParameterString = " {"; + + for (std::map<OUString, OUString>::const_iterator itr = rParameters.begin(); + itr != rParameters.end(); ++itr) + { + if (itr != rParameters.begin()) + aParameterString.append(", "); + aParameterString.append("\"" + itr->first + "\": \"" + itr->second + "\""); + } + + aParameterString.append("}"); + + return aParameterString.makeStringAndClear(); +} + +} + +void UITestLogger::logEvent(const EventDescription& rDescription) +{ + OUString aParameterString = StringMapToOUString(rDescription.aParameters); + + OUString aLogLine = rDescription.aKeyWord + " Action:" + + rDescription.aAction + " Id:" + rDescription.aID + + " Parent:" + rDescription.aParent + aParameterString; + + log(aLogLine); +} + UITestLogger& UITestLogger::getInstance() { ImplSVData *const pSVData = ImplGetSVData(); |