Documentation/4.2/SlicerApplication/QtTesting

From Slicer Wiki
Jump to: navigation, search
Home < Documentation < 4.2 < SlicerApplication < QtTesting


For the latest Slicer documentation, visit the read-the-docs.


3DSlicerQtTesting.png

Overview

Too lazy to do the same actions over and over? QtTesting is the answer! The QtTesting library provides you with an easy way to record and play macros with 3DSlicer. Included in this library is a user-friendly recording interface that shows you what actions you're recording as well as a simple and smart playback interface that will allow you to control actions whenever you want. With no input from the user, QtTesting record all accomplished actions from the point you have started the record until you stop it! "Create a puppet and let it do the rest ... "

Slicer developers use this library to record tutorials and test the 3D Slicer application. How to create you own QtTesting test.


QtTestingMenu.png

Activate QtTesting

By default, QtTesting is not activated. You must enable it to be able to record or play a saved macro.

  • Open the Application Settings dialog.
  • On the left side, select the QtTesting panel
  • Enable QtTesting by toggling the checkbox
  • Restart Slicer

QtTestingSettigns.png


Recorder

Recording a macro consists in observing all the high level events (or low level in some cases) that the user generate by interacting with the GUI elements. All the events are saved into a file (.xml) that can be used later to replay the recorded events in the same or different instance of the Slicer application.

How to record a macro

  • From the menu bar, open the Edit menu and select the Record Macro item to start recording all your following events.

A record dialog appears at the bottom left of the application

Record dialog

  • Shows the last event recorded
  • Numbers of events recorded
  • You can stop the recording anytime by clicking on the Stop button

Save macro

  • When the recording is stopped, a dialog shows up to ask where to save the recorded macro file.

QtTestingRecorderDialog.jpg


Player

Recorded macros (.xml) can be replayed within Slicer sessions. Note that the success of the macro execution can depend on the original state of the application.

How to play a macro

  1. From the menu bar, open the Edit menu and select the Play Macro item to open the player dialog.
  2. Choose the xml macro that you want to play
  3. Press the "Play" button to start executing the macro

Slicer will ask if you want to restore the previously recorded settings. See below

Player dialog

  • Controller widget
    • Play, pause, stop or play-step-by-step your macro.
    • Logs check button shows/hides information about played events and errors if any.
    • Time step controls the playback speed by waiting Xms before playing each event.
  • Player tab (default tab)
    • Show the macro file played.
  • Info tab :
    • Show the last event played.

Default settings recorded

To limit playback problems, QtTesting records automatically some of the applications settings.

  • General settings :
    • The application's geometry
    • The application's state
    • The application's name
    • The application's version
  • 3DSlicer settings :
    • The current layout
    • The current module

Before each play back, the application might have different current settings, QtTesting then asks if you want to restore the settings to the record application state. To maximize the chance of a successful playback, settings must be restored to set the application into a state as much as possible similar to when the macro was recorded.

QtTestintMenuPlayerback.png

QtTestintMacroFileDialog.png

QtTestintPlayererDialog.jpg

QtTestintRestoreSettingsDialog.png

User limitations

QtTesting in 3DSlicer is still under heavy development, some events might not be recorded properly.

What is subject to not work :

  • Some actions under submenus, mainly actions on widget.

Work, but not perfectly:

  • Shifts/offsets might happen when you recording events in the 3D views.