Kaydet (Commit) dd5f8591 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

uitest: start to log key input

We need to disable this part in release builds.

Change-Id: Ica57f8aca1ffb5f7938ab82ef8b888a8d6d6101a
Reviewed-on: https://gerrit.libreoffice.org/35450Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 231070fc
...@@ -30,6 +30,8 @@ public: ...@@ -30,6 +30,8 @@ public:
void log(const OUString& rString); void log(const OUString& rString);
void logKeyInput(VclPtr<vcl::Window>& xUIElement, const KeyEvent& rEvent);
static UITestLogger& getInstance(); static UITestLogger& getInstance();
}; };
......
...@@ -67,6 +67,76 @@ void UITestLogger::log(const OUString& rString) ...@@ -67,6 +67,76 @@ void UITestLogger::log(const OUString& rString)
maStream.WriteLine(OUStringToOString(rString, RTL_TEXTENCODING_UTF8)); maStream.WriteLine(OUStringToOString(rString, RTL_TEXTENCODING_UTF8));
} }
void UITestLogger::logKeyInput(VclPtr<vcl::Window>& xUIElement, const KeyEvent& rEvent)
{
if (!mbValid)
return;
const OUString& rID = xUIElement->get_id();
if (rID.isEmpty())
return;
sal_Unicode nChar = rEvent.GetCharCode();
sal_uInt16 nKeyCode = rEvent.GetKeyCode().GetCode();
bool bShift = rEvent.GetKeyCode().IsShift();
bool bMod1 = rEvent.GetKeyCode().IsMod1();
bool bMod2 = rEvent.GetKeyCode().IsMod1();
bool bMod3 = rEvent.GetKeyCode().IsMod1();
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)
{
if (itr.second == nKeyCode)
{
aFound = itr.first;
break;
}
}
OUString aKeyCode;
if (!aFound.isEmpty() || bShift || bMod1 || bMod2 || bMod3)
{
aKeyCode = "{\"KEYCODE\": \"";
if (bShift)
aKeyCode += "SHIFT+";
if (bMod1)
aKeyCode += "CTRL+";
if (bMod2)
aKeyCode += "ALT+";
if (aFound.isEmpty())
aKeyCode += OUStringLiteral1(nChar) + "\"}";
else
aKeyCode += aFound + "\"}";
}
else
{
aKeyCode = "{\"TEXT\": \"" + OUStringLiteral1(nChar) + "\"}";
}
OUString aContent = "Action on element: " + rID + " with action: TYPE and content: " + aKeyCode;
maStream.WriteLine(OUStringToOString(aContent, RTL_TEXTENCODING_UTF8));
}
UITestLogger& UITestLogger::getInstance() UITestLogger& UITestLogger::getInstance()
{ {
static UITestLogger aInstance; static UITestLogger aInstance;
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <vcl/virdev.hxx> #include <vcl/virdev.hxx>
#include <vcl/lazydelete.hxx> #include <vcl/lazydelete.hxx>
#include <touch/touch.h> #include <touch/touch.h>
#include <vcl/uitest/logger.hxx>
#include <svdata.hxx> #include <svdata.hxx>
#include <salwtype.hxx> #include <salwtype.hxx>
...@@ -986,6 +987,7 @@ static bool ImplHandleKey( vcl::Window* pWindow, MouseNotifyEvent nSVEvent, ...@@ -986,6 +987,7 @@ static bool ImplHandleKey( vcl::Window* pWindow, MouseNotifyEvent nSVEvent,
{ {
if ( nSVEvent == MouseNotifyEvent::KEYINPUT ) if ( nSVEvent == MouseNotifyEvent::KEYINPUT )
{ {
UITestLogger::getInstance().logKeyInput(pChild, aKeyEvt);
pChild->ImplGetWindowImpl()->mbKeyInput = false; pChild->ImplGetWindowImpl()->mbKeyInput = false;
pChild->KeyInput( aKeyEvt ); pChild->KeyInput( aKeyEvt );
} }
......
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