📜 ⬆️ ⬇️

Organization of automated testing GUI

When developing, we try to cover our code not only with obscenities, but also with unit tests. However, it is not always possible to cover everything with tests. In addition, there is a GUI , for which writing tests is quite a laborious job. With all these problems, the requirement remains that every next commit to the repository should not spoil the existing functionality.

In this article I want to tell you what tools we use to test our desktop applications written in Qt.

Half a year ago, in the course of researching GUI testing tools, Squish of froglogic came into my field of vision. The advantages of this solution include the following:
')


On the other scales weighing the license cost 93,000 rubles. (This is at the August exchange rate of 2650 euros).

Since none of the competitors offered such goodies for such money, and I did not find similar free solutions, reluctantly I bought a license.

So, with the background completed, proceed to the creation of tests. For the demonstration, I chose one of our public projects - MDC . The task is simple, check whether MDC can connect to ICQ, Gtalk, mail.ru. The topic is especially relevant in the light of the latest AOL company surprises :). A sign of connection will be considered the appearance of the contact sheet window.

  1. We collect Squish from source codes with the same version of Qt with which MDC will be compiled.
  2. We collect debug MDC mode (cannot work with release Squish).
  3. Run Squish.
  4. Create Test Suit for MDC.
  5. We choose the language in which we will write tests.
  6. Configure application launch parameters (command line parameters, environment variables, etc.).
  7. Create a new test case in record mode (Squish runs the MDC and remembers all the actions you create with the application as a script).
  8. Checking his work.




So we got the text of the test, which we will use as a basis.

def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  1. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  2. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  3. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  4. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  5. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  6. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  7. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  8. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  9. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  10. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  11. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  12. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  13. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  14. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  15. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  16. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  17. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  18. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  19. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  20. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
  21. def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .
def main(): waitForObject( ":_QWidget" ) sendEvent( "QResizeEvent" , ":_QWidget" , 22, 22, 769, 474) waitForObject( ":_QGraphicsItem" ) mouseClick( ":_QGraphicsItem" , 221, 193, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) dragItemBy( ":_QLineEdit" , 153, -191, 26, 198, 1, Qt.LeftButton) waitForObject( ":_QLineEdit" ) sendEvent( "QMouseEvent" , ":_QLineEdit" , QEvent.MouseButtonRelease, 179, 7, Qt.LeftButton, 1) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Ctrl+A>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "squish@mail.ru" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "<Tab>" ) waitForObject( ":MDC: _QGraphicsView" ) type( ":MDC: _QGraphicsView" , "1234" ) waitForObject( ":MDC: _CStartUpWidget" ) sendEvent( "QMoveEvent" , ":MDC: _CStartUpWidget" , 577, 70, 734, 62) mouseClick( ":MDC: _QWidget" , 66, 372, 1, Qt.LeftButton) waitForObject( ":MDC v1.0.3.1.nightly_CContactListWidget" ) * This source code was highlighted with Source Code Highlighter .


Of course, using this text without changes is also possible for a wide range of tasks, which makes it possible for Squish to work with not only developers, but also less qualified employees, but this code is not suitable for our task.

Squish supports 2 types of object naming: symbolic name and real name. When automatically creating text for a test, Squish uses a symbolic name, which is not always convenient. So, for example, the contact sheet window is automatically defined as

symbolic name: MDC v1.0.3.1.nightly_CContactListWidget

where MDC v1.0.3.1. nightly is the title of the window, and CContactListWidget is the type of this widget. In the window header there is a version that will obviously change and the object specified in this way will never be found. In this case, you must use the real name: {name = 'contactList' type = 'CContactListWidget' visible = '1'}. Where name is set by constant in MDC code via setObjectName

  1. m_widget = new CContactListWidget (this_ptr);
  2. m_widget-> setObjectName ( "contactList" );
* This source code was highlighted with Source Code Highlighter .


Thus, regardless of the window title, we can always find the widget we need and the final code of our test will look like this:

  1. def main ():
  2. waitForObject ( ": _QWidget" )
  3. sendEvent ( "QResizeEvent" , ": _QWidget" , 22, 22, 629, 418)
  4. waitForObject ( ": _QLineEdit" )
  5. dragItemBy ( ": _QLineEdit" , 140, -183, 26, 198, 1, Qt.LeftButton)
  6. waitForObject ( ": _QLineEdit" )
  7. sendEvent ( "QMouseEvent" , ": _QLineEdit" , QEvent. MouseButtonRelease, 166, 15, Qt.LeftButton, 1)
  8. waitForObject ( ": MDC: Authorization_QGraphicsView" )
  9. type ( ": MDC: QGraphicsView Authorization" , "<Ctrl + A>" )
  10. waitForObject ( ": MDC: Authorization_QGraphicsView" )
  11. type ( ": MDC: QGraphicsView Authorization" , "squish@mail.ru" )
  12. waitForObject ( ": MDC: Authorization_QGraphicsView" )
  13. type ( ": MDC: QGraphicsView Authorization" , "<Tab>" )
  14. waitForObject ( ": MDC: Authorization_QGraphicsView" )
  15. type ( ": MDC: QGraphicsView Authorization" , "1234" )
  16. mouseClick ( ": MDC: QWidget Authorization" , 154, 369, 1, Qt.LeftButton)
  17. waitForObject ( ": {name = 'contactList' type = 'CContactListWidget' visible = '1'}" )
* This source code was highlighted with Source Code Highlighter .


It is easy to make a script to test the connection to jabber and icq from it, replacing the login, password and click coordinates. The video below shows the launch of the test suit, consisting of three test cases (icq, mail.ru, jabber)



After that, this test suit can be made to run after unit tests have been completed at each subsequent session, so that you always have such a beautiful picture at hand:



But this is another story, about which, if it will be interesting, I will also be happy to write.

In this article, I just casually touched upon the functionality of Squish deliberately without touching on such issues as synchronization primitives, working with Qt objects through an API. I plan to write about these things in the following posts.

Source: https://habr.com/ru/post/54614/


All Articles