Testing Qt Application Manager applications with Squish.

Qt Application Manager (or appman) is a Qt module targeted for embedded devices. It allows you to create rich, Qt Quick-based user interfaces. The module exports an API that allows the Qt Quick GUI to act as a compositing display manager. It supports installing, removing, and life-cycle management of applications. Testing applications written for appman is challenging for a number of reasons.

Appman uses Wayland for desktop compositing. Some compositor setups do not support the full set of features yet, such as those needed for the Squish widget highlighter. The upcoming Squish 6.3 release contains a number of Wayland support improvements to deal with these limitations.

Testing the Applications

Since applications written for the Qt Application Manager are tightly coupled to it, the entire appman should be registered as the AUT, and the “Hook into sub-processes launched by the application” option in the “Test Suite Settings” page should be enabled. The test scripts can then start the required applications (if not started by default) by interacting with the GUI. Recording the test script should correctly recognize multiple sub-processes and record a valid test script just like it does with unrelated applications.

The Application Manager uses the same launcher for each Qt Quick application. This can make it difficult to find the right application context when switching between different applications – especially if multiple applications are started simultaneously. To address this, you can access the appman application ID and other meta information by accessing the application interface object properties:

function appmanApplicationId()
{
    try {
        var window = findObject("{type='QtAM::ApplicationManagerWindow'}");
        var appInterface = QQmlEngine.contextForObject( window )
                             .contextProperty("ApplicationInterface");
        if ( !appInterface.isValid() ) {
            return undefined;
        }
        return object.convertTo( appInterface, "QObject" ).applicationId;
    } catch ( e )
    {
        return undefined;
    }
}

Application hooking troubleshooting

If the applications are not hooked properly, it is possible that some of the relevant environment variables were overwritten. Appman allows configuring environment variables for each application. The LD_LIBRARY_PATH environment variable is often configured by the application developers in order to correctly resolve the dependency libraries. This can lead to clashes against Squish as it needs a correct library path contained in that variable in order to successfully hook the application. The environment variables can be set in any of the following files:

  • Appman‘s internal configuration ( usually at /opt/am/config.yaml ) under runtimes: qml: environmentVariables section;
  • The global configuration ( usually am-config.yaml ) under runtimes: qml: environmentVariables section;
  • The application configuration file ( usually at apps/<app-id>/info.yaml ) under environmentVariables section.

If any of the above configuration files specifies the LD_LIBRARY_PATH environment variable, it’s value will be replaced by the configured string and application will not be hooked by Squish. In this case, you can use the lib directory path of your Squish installation in the relevant configuration file locations. If modification of the application configuration for testing purposes is not desired, you can create a wrapper around the Qt Quick launcher on your test system. Rename the appman-launcher-qml executable in your Qt installation to appman-launcher-qml.orig, and create a wrapper script under the same name that runs the original launcher with a modified environment:

#!/bin/sh

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<Squish installation path>/lib

"$0.orig" "$@"

For QtQuick applications, the Qt Application Manager also supports a single-process mode, which reduces complexity and simplifies hooking. However, tests recorded in one of the modes will not replay in the other, due to the application context switching.

Conclusion

The Qt Application Manager is a complex piece of QML software, resembling a desktop or a window manager, using QtQuick features for compositing. Its purpose is to start and manage other QtQuick applications, and is suited for embedded systems. Squish has been tested with it on many platforms, and has improved its support for testing applications that are packaged in this way.

0 Comments

Leave a reply

Your email address will not be published. Required fields are marked *

*