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

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: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 05139974
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <map>
struct EventDescription
{
OUString aKeyWord, aAction, aID, aParent;
std::map<OUString, OUString> aParameters;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
......@@ -11,6 +11,13 @@
#include <tools/stream.hxx>
#include <vcl/ctrl.hxx>
#include <com/sun/star/uno/Sequence.hxx>
namespace com { namespace sun { namespace star {
namespace beans { struct PropertyValue; }
} } }
struct EventDescription;
class UITEST_DLLPUBLIC UITestLogger
{
......@@ -24,7 +31,7 @@ public:
UITestLogger();
void logCommand(const OUString& rAction);
void logCommand(const OUString& rAction, const css::uno::Sequence<css::beans::PropertyValue>& rArgs);
void logAction(VclPtr<Control> const & xUIElement, VclEventId nEvent);
......@@ -32,6 +39,8 @@ public:
void logKeyInput(VclPtr<vcl::Window> const & xUIElement, const KeyEvent& rEvent);
void logEvent(const EventDescription& rDescription);
static UITestLogger& getInstance();
};
......
......@@ -140,6 +140,8 @@
#include <svx/sdrpagewindow.hxx>
#include <svx/sdr/overlay/overlaymanager.hxx>
#include <vcl/svapp.hxx>
#include <vcl/uitest/logger.hxx>
#include <vcl/uitest/eventdescription.hxx>
#include <svx/sdr/overlay/overlayselection.hxx>
#include <comphelper/string.hxx>
#include <comphelper/lok.hxx>
......@@ -619,6 +621,19 @@ public:
}
};
void collectUIInformation(const OUString& aRow, const OUString& aCol)
{
EventDescription aDescription;
aDescription.aAction = "LAUNCH";
aDescription.aID = "grid_window";
aDescription.aParameters = {{"AUTOFILTER", ""},
{"ROW", aRow}, {"COL", aCol}};
aDescription.aParent = "MainWindow";
aDescription.aKeyWord = "ScGridWinUIObject";
UITestLogger::getInstance().logEvent(aDescription);
}
}
void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
......@@ -705,6 +720,8 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
aConfig.mbRTL = pViewData->GetDocument()->IsLayoutRTL(pViewData->GetTabNo());
mpAutoFilterPopup->setConfig(aConfig);
mpAutoFilterPopup->launch(aCellRect);
collectUIInformation(OUString::number(nRow), OUString::number(nCol));
}
void ScGridWindow::RefreshAutoFilterButton(const ScAddress& rPos)
......
......@@ -30,6 +30,8 @@
#include <sfx2/lokhelper.hxx>
#include <sfx2/viewfrm.hxx>
#include <vcl/cursor.hxx>
#include <vcl/uitest/logger.hxx>
#include <vcl/uitest/eventdescription.hxx>
#include <tabview.hxx>
#include <tabvwsh.hxx>
......@@ -326,6 +328,22 @@ void ScTabView::InvalidateAttribs()
rBindings.Invalidate( SID_NUMBER_THOUSANDS );
}
namespace {
void collectUIInformation(const std::map<OUString, OUString>& aParameters)
{
EventDescription aDescription;
aDescription.aID = "grid_window";
aDescription.aAction = "SELECT";
aDescription.aParameters = aParameters;
aDescription.aParent = "MainWindow";
aDescription.aKeyWord = "ScGridWinUIObject";
UITestLogger::getInstance().logEvent(aDescription);
}
}
// SetCursor - Cursor, set, draw, update InputWin
// or send reference
// Optimising breaks the functionality
......@@ -361,6 +379,9 @@ void ScTabView::SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew )
CursorPosChanged();
OUString aCurrAddress = ScAddress(nPosX,nPosY,0).GetColRowString();
collectUIInformation({{"CELL", aCurrAddress}});
if (comphelper::LibreOfficeKit::isActive())
{
if (nPosX > aViewData.GetMaxTiledCol() - 10 || nPosY > aViewData.GetMaxTiledRow() - 25)
......@@ -430,6 +451,17 @@ void ScTabView::CheckSelectionTransfer()
pScMod->SetSelectionTransfer( pNew.get() );
pNew->CopyToSelection( GetActiveWin() ); // may delete pOld
// Log the selection change
ScMarkData& rMark = aViewData.GetMarkData();
if (rMark.IsMarked())
{
ScRange aMarkRange;
rMark.GetMarkArea( aMarkRange );
OUString aStartAddress = aMarkRange.aStart.GetColRowString();
OUString aEndAddress = aMarkRange.aEnd.GetColRowString();
collectUIInformation({{"RANGE", aStartAddress + ":" + aEndAddress}});
}
}
else if ( pOld && pOld->GetView() == this )
{
......@@ -1868,6 +1900,7 @@ void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool bExtendSelection, bool bSa
}
TabChanged(bSameTabButMoved); // DrawView
collectUIInformation({{"TABLE", OUString::number(nTab)}});
UpdateVisibleRange();
aViewData.GetViewShell()->WindowChanged(); // if the active window has changed
......
......@@ -79,6 +79,8 @@
#include <sfx2/request.hxx>
#include <comphelper/lok.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <vcl/uitest/logger.hxx>
#include <vcl/uitest/eventdescription.hxx>
using namespace com::sun::star;
......@@ -262,6 +264,22 @@ void DrawViewShell::SelectionHasChanged()
GetViewShellBase().GetDrawController().FireSelectionChangeListener();
}
namespace {
void collectUIInformation(const OUString& aZoom)
{
EventDescription aDescription;
aDescription.aID = "impress_win";
aDescription.aParameters = {{"ZOOM", aZoom}};
aDescription.aAction = "SET";
aDescription.aKeyWord = "ImpressWindowUIObject";
aDescription.aParent = "MainWindow";
UITestLogger::getInstance().logEvent(aDescription);
}
}
/**
* set zoom factor
*/
......@@ -274,6 +292,7 @@ void DrawViewShell::SetZoom( long nZoom )
GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
mpViewOverlayManager->onZoomChanged();
collectUIInformation(OUString::number(nZoom));
}
/**
......
......@@ -594,13 +594,13 @@ void collectUsageInformation(const util::URL& rURL, const uno::Sequence<beans::P
theUsageInfo::get().increment(aCommand);
}
void collectUIInformation(const util::URL& rURL)
void collectUIInformation(const util::URL& rURL, const css::uno::Sequence< css::beans::PropertyValue >& rArgs)
{
static const char* pFile = std::getenv("LO_COLLECT_UIINFO");
if (!pFile)
return;
UITestLogger::getInstance().logCommand("CommandSent Name:" + rURL.Complete);
UITestLogger::getInstance().logCommand("CommandSent Name:" + rURL.Complete, rArgs);
}
}
......@@ -610,7 +610,7 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL,
const css::uno::Reference< css::frame::XDispatchResultListener >& rListener )
{
collectUsageInformation(aURL, aArgs);
collectUIInformation(aURL);
collectUIInformation(aURL,aArgs);
SolarMutexGuard aGuard;
if (
......
......@@ -37,6 +37,8 @@
#include <framework/ContextChangeEventMultiplexerTunnel.hxx>
#include <vcl/floatwin.hxx>
#include <vcl/fixed.hxx>
#include <vcl/uitest/logger.hxx>
#include <vcl/uitest/eventdescription.hxx>
#include <splitwin.hxx>
#include <tools/link.hxx>
#include <toolkit/helper/vclunohelper.hxx>
......@@ -514,6 +516,21 @@ void SidebarController::UpdateConfigurations()
}
}
namespace {
void collectUIInformation(const OUString& rDeckId)
{
EventDescription aDescription;
aDescription.aAction = "SIDEBAR";
aDescription.aParent = "MainWindow";
aDescription.aParameters = {{"PANEL", rDeckId}};
aDescription.aKeyWord = "CurrentApp";
UITestLogger::getInstance().logEvent(aDescription);
}
}
void SidebarController::OpenThenToggleDeck (
const OUString& rsDeckId)
{
......@@ -540,6 +557,7 @@ void SidebarController::OpenThenToggleDeck (
SwitchToDeck(rsDeckId);
mpTabBar->Invalidate();
mpTabBar->HighlightDeck(rsDeckId);
collectUIInformation(rsDeckId);
}
void SidebarController::OpenThenSwitchToDeck (
......
......@@ -36,6 +36,8 @@
#include <sfx2/sfxmodelfactory.hxx>
#include <vcl/help.hxx>
#include <vcl/settings.hxx>
#include <vcl/uitest/logger.hxx>
#include <vcl/uitest/eventdescription.hxx>
SmElement::SmElement(std::unique_ptr<SmNode>&& pNode, const OUString& aText, const OUString& aHelpText) :
mpNode(std::move(pNode)),
......@@ -482,19 +484,37 @@ void SmElementsControl::MouseMove( const MouseEvent& rMouseEvent )
Control::MouseMove(rMouseEvent);
}
namespace {
void collectUIInformation(const OUString& aID)
{
EventDescription aDescription;
aDescription.aID = aID;
aDescription.aParent = "element_selector";
aDescription.aAction = "SELECT";
aDescription.aKeyWord = "ElementUIObject";
UITestLogger::getInstance().logEvent(aDescription);
}
}
void SmElementsControl::MouseButtonDown(const MouseEvent& rMouseEvent)
{
GrabFocus();
if (rMouseEvent.IsLeft() && tools::Rectangle(Point(0, 0), GetOutputSizePixel()).IsInside(rMouseEvent.GetPosPixel()) && maSelectHdlLink.IsSet())
{
for (std::unique_ptr<SmElement> & i : maElementList)
sal_uInt16 nElementCount = maElementList.size();
for (sal_uInt16 n = 0; n < nElementCount; n++)
{
std::unique_ptr<SmElement> & i = maElementList[n];
SmElement* element = i.get();
tools::Rectangle rect(element->mBoxLocation, element->mBoxSize);
if (rect.IsInside(rMouseEvent.GetPosPixel()))
{
maSelectHdlLink.Call(*element);
collectUIInformation(OUString::number(n));
return;
}
}
......
......@@ -48,6 +48,8 @@
#include <svx/sdrhittesthelper.hxx>
#include <svx/svdocapt.hxx>
#include <svx/svdograf.hxx>
#include <vcl/uitest/logger.hxx>
#include <vcl/uitest/eventdescription.hxx>
#include <editeng/editdata.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
......@@ -1634,6 +1636,25 @@ void SdrMarkView::MarkObj(const tools::Rectangle& rRect, bool bUnmark)
}
}
namespace {
void collectUIInformation(SdrObject* pObj)
{
EventDescription aDescription;
aDescription.aAction = "SELECT";
aDescription.aParent = "MainWindow";
aDescription.aKeyWord = "CurrentApp";
if (!pObj->GetName().isEmpty())
aDescription.aParameters = {{"OBJECT", pObj->GetName()}};
else
aDescription.aParameters = {{"OBJECT", "Unnamed_Obj_" + OUString::number(pObj->GetOrdNum())}};
UITestLogger::getInstance().logEvent(aDescription);
}
}
void SdrMarkView::MarkObj(SdrObject* pObj, SdrPageView* pPV, bool bUnmark, bool bImpNoSetMarkHdl)
{
if (pObj!=nullptr && pPV!=nullptr && IsObjMarkable(pObj, pPV)) {
......@@ -1641,6 +1662,7 @@ void SdrMarkView::MarkObj(SdrObject* pObj, SdrPageView* pPV, bool bUnmark, bool
if (!bUnmark)
{
GetMarkedObjectListWriteAccess().InsertEntry(SdrMark(pObj,pPV));
collectUIInformation(pObj);
}
else
{
......
......@@ -68,6 +68,8 @@
#include <editeng/editview.hxx>
#include <PostItMgr.hxx>
#include <DocumentSettingManager.hxx>
#include <vcl/uitest/logger.hxx>
#include <vcl/uitest/eventdescription.hxx>
using namespace com::sun::star;
using namespace util;
......@@ -1067,6 +1069,21 @@ bool SwCursorShell::SetInFrontOfLabel( bool bNew )
return false;
}
namespace {
void collectUIInformation(const OUString& aPage)
{
EventDescription aDescription;
aDescription.aAction = "GOTO";
aDescription.aParameters = {{"PAGE", aPage}};
aDescription.aID = "writer_edit";
aDescription.aKeyWord = "SwEditWinUIObject";
aDescription.aParent = "MainWindow";
UITestLogger::getInstance().logEvent(aDescription);
}
}
bool SwCursorShell::GotoPage( sal_uInt16 nPage )
{
SET_CURR_SHELL( this );
......@@ -1077,6 +1094,8 @@ bool SwCursorShell::GotoPage( sal_uInt16 nPage )
SwCursorSelOverFlags::ChangePos );
if( bRet )
UpdateCursor(SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE|SwCursorShell::READONLY);
collectUIInformation(OUString::number(nPage));
return bRet;
}
......
......@@ -53,11 +53,29 @@
#include <svx/srchdlg.hxx>
#include <vcl/uitest/logger.hxx>
#include <vcl/uitest/eventdescription.hxx>
sal_uInt16 SwView::m_nMoveType = NID_PGE;
sal_Int32 SwView::m_nActMark = 0;
using namespace ::com::sun::star::uno;
namespace {
void collectUIInformation(const OUString& aFactor)
{
EventDescription aDescription;
aDescription.aID = "writer_edit";
aDescription.aParameters = {{"ZOOM", aFactor}};
aDescription.aAction = "SET";
aDescription.aKeyWord = "SwEditWinUIObject";
aDescription.aParent = "MainWindow";
UITestLogger::getInstance().logEvent(aDescription);
}
}
void SwView::SetZoom( SvxZoomType eZoomType, short nFactor, bool bViewOnly )
{
bool const bCursorIsVisible(m_pWrtShell->IsCursorVisible());
......@@ -65,6 +83,8 @@ void SwView::SetZoom( SvxZoomType eZoomType, short nFactor, bool bViewOnly )
// fdo#40465 force the cursor to stay in view whilst zooming
if (bCursorIsVisible)
m_pWrtShell->ShowCursor();
collectUIInformation(OUString::number(nFactor));
}
void SwView::SetZoom_( const Size &rEditSize, SvxZoomType eZoomType,
......
......@@ -40,6 +40,8 @@
#include <doc.hxx>
#include <wordcountdialog.hxx>
#include <memory>
#include <vcl/uitest/logger.hxx>
#include <vcl/uitest/eventdescription.hxx>
namespace com { namespace sun { namespace star { namespace util {
struct SearchOptions2;
......@@ -388,6 +390,25 @@ void SwWrtShell::SttSelect()
SwTransferable::CreateSelection( *this );
}
namespace {
void collectUIInformation(SwShellCursor* pCursor)
{
EventDescription aDescription;
OUString aSelStart = OUString::number(pCursor->Start()->nContent.GetIndex());
OUString aSelEnd = OUString::number(pCursor->End()->nContent.GetIndex());
aDescription.aParameters = {{"START_POS", aSelStart}, {"END_POS", aSelEnd}};
aDescription.aAction = "SELECT";
aDescription.aID = "writer_edit";
aDescription.aKeyWord = "SwEditWinUIObject";
aDescription.aParent = "MainWindow";
UITestLogger::getInstance().logEvent(aDescription);
}
}
// End of a selection process.
void SwWrtShell::EndSelect()
......@@ -409,6 +430,8 @@ void SwWrtShell::EndSelect()
SwWordCountWrapper *pWrdCnt = static_cast<SwWordCountWrapper*>(GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId()));
if (pWrdCnt)
pWrdCnt->UpdateCounts();
collectUIInformation(GetCursor_());
}
void SwWrtShell::ExtSelWrd(const Point *pPt, bool )
......
......@@ -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();
......
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