Installing Squish for Qt for Android testing

The Squish for Qt for Android testing package is suitable for preparing a Qt on Android application for testing. You also need a Squish for Qt package on your desktop machine for recording, managing and replaying tests. Please see Installing from Binary Packages for details on installing such a package.

In order to build your application instrumented for using with Squish for Qt on Android, you have to unpack the package and do a build of your application with Squish's Qt support included in the build, followed by deploying the application:

  1. Add the following to your applications qmake project file:
    SQUISH_ATTACH_PORT = portnumber
    include(/path-to-squish/qtbuiltinhook.pri)

    <path-to-squish> has to be replaced with the full path to the location where you unpacked Squish for Qt for Android.

    <portnumber> has to be replaced by a freely choosen TCP port number that is greater than 1024. It will be used to attach to the application.

  2. Ensure your project is deployed with Qt libraries as part of your APK. Using the Ministro service to install Qt is unlikely to work. This setting can be found in Qt Creator in Projects, Build, Build Steps, Build Android APK, Additional Libraries. Outside of Qt Creator this can be configured via a commandline argument of androiddeployqt (see also https://doc.qt.io/qt-5/deployment-android.html).
  3. In Qt Creator choose Clean, to ensure that qmake picks up all parts of Squish for Qt to include them in the final application package. Afterwards choose Run or Debug to build, deploy and run the application on the device.
  4. The application should be running on the Android device now. The Application Output in Qt Creator should (among other log output) show several lines starting with the word Squish, including Squish: Listening on port 4567 for incoming connections where 4567 is the port number specified earlier in the qmake project file.
  5. If the application is running inside the Android Emulator or if testing over a USB connection is required, the TCP port will need to be forwarded to the desktop machine in order to attach to the AUT. To do that, call the following from a commandline prompt on the desktop machine:
    $ adb forward tcp:portnumber tcp:portnumber

    Again replace <portnumber> with the one set in the qmake project file. The adb commandline tool is part of Android Studio.

  6. If not done already, install a Squish for Qt binary package on the desktop machine. For remote testing Qt on Android the Qt version and compiler version of this package do not matter.
  7. In squishide choose File, New Test Suite to create a new Test Suite and follow the wizard. When asked for the GUI Toolkit choose Qt. When asked for the Application Under Test choose <No Application>.
  8. Follow the steps from Register the Attachable AUT to register the application as an attachable AUT. In case TCP port forwarding via ADB is used, the Host will be localhost.

To verify if the AUT is accepting incoming connections the output of netstat can be used (for a Windows command prompt replace grep with findstr)

$ adb shell netstat -a | grep portnumber
 tcp       0      0 0.0.0.0:portnumber   0.0.0.0:*        LISTEN

Attaching to the running AUT will work if an entry with state LISTEN and the previously passed portnumber is present in the tabular output.