An overview of how UI logging works in LibreOffice

Logging in LibreOffice is mainly handled by a class called UITestLogger, defined here. The logger class logs the user actions only if the member flag mbValid is set to true. The flag can be turned on by setting the environment variable LO_COLLECT_UIINFO to a file name where the logs should be collected (see the constructor of UITestLogger, defined here).

We maintain a pointer to an instance of UITestLogger class here. To use the logger object, the static function getInstance can be used to get access to the pointer.

The function logAction, defined in the same class, is used to log events from the classes which extend the class vcl::Control. The log statements corresponding to a particular class can be found in the function get_action of the UI wrapper classes. Most of the wrapper classes can be found with this OpenGrok search. The log statements get generated when VCL events get broadcasted. A list of the VCL events can be found in the enum class VclEventId here.

For other classes, we have functions named collectUIInformation spread in different places of the code (This OpenGrok search might be helpful). These functions collect information about an event and store it in a struct EventDescription (defined here) and pass it to another function of UITestLogger, called logEvent. The logEvent function constructs a log string using the information provided by the given event description, and finally logs the statement using the file stream maStream.

The log interpreter (made here) can be used to convert the log file into a UI test case. It interprets the log file line-by-line and converts every line into a python dictionary. The dictionaries are then used to generate statements readable by the UI testing framework.

PS: This blog post is an effort to document (and provide code-pointers for) the UI Test logger, parts of which were developed during GSoC 2018. The final report of the GSoC project can be found at GSoC final report - UI logger.


Popular posts from this blog

GSoC final report - UI logger

GSoC work report - Week 11