Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Best way to run gui tests without widgets becoming visible?
Qt 6.11 is out! See what's new in the release blog

Best way to run gui tests without widgets becoming visible?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 2.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    patrickkidd
    wrote on last edited by
    #1

    I am writing unit and integration tests for my QWindow app and am trying to figure out how to keep widgets from displaying during the tests. This has gone mostly well so far, with some occasional exceptions.

    For example, if I select a QComboBox item using kb and mouse emulation with the following code, the list view for the QComboBox becomes visible just before and just after the selection is made:

    def selectComboBoxItem(self, cb, s):
        self.mouseClick(cb)
        self.qWait(100)
        lv = cb.findChild(QListView)
        for row in range(lv.model().rowCount()):
            index = lv.model().index(row, 0)
            lv.scrollTo(index)
            itemP = lv.visualRect(index).center()
            itemS = lv.model().index(row, 0).data(Qt.DisplayRole)
            if not itemP.isNull() and itemS == s:
                self.qWait(100)
                self.mouseClick(lv.viewport(), Qt.LeftButton, Qt.NoModifier, itemP)
                return True
    return False
    

    Is there a way to run gui tests without ever showing a widget? Surely this would be a requirement for any automated test system.

    Thanks!

    https://alaskafamilysystems.com/

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @patrickkidd said in Best way to run gui tests without widgets becoming visible?:

      Is there a way to run gui tests without ever showing a widget?

      No

      Surely this would be a requirement for any automated test system.

      Then the automated integration tests for Qt would not work at all...

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      P 1 Reply Last reply
      5
      • Christian EhrlicherC Christian Ehrlicher

        @patrickkidd said in Best way to run gui tests without widgets becoming visible?:

        Is there a way to run gui tests without ever showing a widget?

        No

        Surely this would be a requirement for any automated test system.

        Then the automated integration tests for Qt would not work at all...

        P Offline
        P Offline
        patrickkidd
        wrote on last edited by
        #3

        @Christian-Ehrlicher so the qt tests pop a widget for every test that uses one? It seems like that would add quite a bit of execution time. Or am I misunderstanding you?

        https://alaskafamilysystems.com/

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Yes, widgets are shown as needed. They have no physical representation until visible so depending on the test you do there’s no way to run it without them being shown.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          P 1 Reply Last reply
          2
          • SGaistS SGaist

            Hi,

            Yes, widgets are shown as needed. They have no physical representation until visible so depending on the test you do there’s no way to run it without them being shown.

            P Offline
            P Offline
            patrickkidd
            wrote on last edited by
            #5

            @SGaist thanks for that. How great that we have so many examples in the qt tests to learn from.

            https://alaskafamilysystems.com/

            1 Reply Last reply
            0
            • W Offline
              W Offline
              wrosecrans
              wrote on last edited by
              #6

              On Linux, you can run your app inside xvfb, and it'll strictly render offscreen in a virtual framebuffer. (Probably won't work if you are doing interesting OpenGL stuff, but normal widgets doing software rendering works fine.) You can even automate the generation of a screenshot at a certain point in the tests.

              It's fairly easy to set up on a CI server with no GPU or actual display. The software thinking it's being displayed on a normal screen. You can set up multiple xvfb instances in parallel to act is different X displays, so you can have multiple "full screen" apps running at once, because they are all independent.

              1 Reply Last reply
              3

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved