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. Writing tests for tableview and delegate subclasses.
Forum Updated to NodeBB v4.3 + New Features

Writing tests for tableview and delegate subclasses.

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 3 Posters 2.5k 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 patrickkidd

    Hello!

    I am writing tests for my qtableview subclass which uses a custom model and custom delegate for editable cells. I am having trouble finding examples in the qt tests for opening an editor. This was (and still is) a pain for my qlistview subclass so I am looking for example code up front.

    Does anyone know where to look for good item view unit test example code?

    -Patrick

    raven-worxR Offline
    raven-worxR Offline
    raven-worx
    Moderators
    wrote on last edited by
    #2

    @patrickkidd
    u know the QtTest module already?

    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
    If you have a question please use the forum so others can benefit from the solution in the future

    P 1 Reply Last reply
    0
    • raven-worxR raven-worx

      @patrickkidd
      u know the QtTest module already?

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

      @raven-worx said in Writing tests for tableview and delegate subclasses.:

      @patrickkidd
      u know the QtTest module already?

      Yes, I am asking about the specifics of using it with item views. It is not always straightforward to get the intended behavior.

      https://alaskafamilysystems.com/

      raven-worxR 1 Reply Last reply
      0
      • P patrickkidd

        @raven-worx said in Writing tests for tableview and delegate subclasses.:

        @patrickkidd
        u know the QtTest module already?

        Yes, I am asking about the specifics of using it with item views. It is not always straightforward to get the intended behavior.

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #4

        @patrickkidd
        whats the special case you want to test with item views?!

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        P 1 Reply Last reply
        0
        • raven-worxR raven-worx

          @patrickkidd
          whats the special case you want to test with item views?!

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

          @raven-worx said in Writing tests for tableview and delegate subclasses.:

          @patrickkidd
          whats the special case you want to test with item views?!

          My case is pretty standard, just item delegates with custom editors. Writing basic tests for widgets is not always straightforward as they don't behave as you think they would, they need custom qWait calls, they don't respond to tab keys the right way, sometimes you have to fudge widget focus, things like that.

          So my question is about finding example unit test code so I don' have to waste a ton of time debugging.

          https://alaskafamilysystems.com/

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

            Did you already take a look at the qt autotests?
            e.g. http://code.qt.io/cgit/qt/qtbase.git/tree/tests/auto/widgets/itemviews/qitemdelegate?h=5.3

            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
            1
            • Christian EhrlicherC Christian Ehrlicher

              Did you already take a look at the qt autotests?
              e.g. http://code.qt.io/cgit/qt/qtbase.git/tree/tests/auto/widgets/itemviews/qitemdelegate?h=5.3

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

              @Christian-Ehrlicher As mentioned in the original post, yes. I looked in the tableview, list view, and itemdelegate tests and these open the editors programmatically, for example. I am trying to test the interactivity with mouse clicks for example.

              https://alaskafamilysystems.com/

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

                Simulating mouse clicks will only work on xcb, not on windows. Therefore I would avoid it.

                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
                1
                • Christian EhrlicherC Christian Ehrlicher

                  Simulating mouse clicks will only work on xcb, not on windows. Therefore I would avoid it.

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

                  @Christian-Ehrlicher said in Writing tests for tableview and delegate subclasses.:

                  Simulating mouse clicks will only work on xcb, not on windows. Therefore I would avoid it.

                  OK. Then are you saying that it is standard practice to write tests which programmatically interact with item views as opposed to using mouse events?

                  https://alaskafamilysystems.com/

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

                    If you need real mouse interactions I would suggest using a framework like Squish ( https://www.froglogic.com/ )

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

                    P 2 Replies Last reply
                    0
                    • Christian EhrlicherC Christian Ehrlicher

                      If you need real mouse interactions I would suggest using a framework like Squish ( https://www.froglogic.com/ )

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

                      @Christian-Ehrlicher Yeah, that one looks like a great framework. Too bad how expensive it is though...

                      https://alaskafamilysystems.com/

                      1 Reply Last reply
                      0
                      • Christian EhrlicherC Christian Ehrlicher

                        If you need real mouse interactions I would suggest using a framework like Squish ( https://www.froglogic.com/ )

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

                        I am still wondering what the common testing practices is for item views in Qt, or any other graphical elements that do no behave as straightforwardly as one would assume looking at the QTest documentation.

                        What does this look like in real life? Am I making a big deal out of nothing here? Do people just get by with programatic control of some widgets? What does experience say?

                        https://alaskafamilysystems.com/

                        raven-worxR 1 Reply Last reply
                        0
                        • P patrickkidd

                          I am still wondering what the common testing practices is for item views in Qt, or any other graphical elements that do no behave as straightforwardly as one would assume looking at the QTest documentation.

                          What does this look like in real life? Am I making a big deal out of nothing here? Do people just get by with programatic control of some widgets? What does experience say?

                          raven-worxR Offline
                          raven-worxR Offline
                          raven-worx
                          Moderators
                          wrote on last edited by raven-worx
                          #13

                          @patrickkidd
                          there is a big difference between Unit testing and GUI testing frameworks.
                          The later is more complex obviously.

                          Beside squish (which needs to be compiled against the same Qt version) there is also Ranorex (which uses the accessibility feature of Qt)

                          Probably there are more out there

                          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                          If you have a question please use the forum so others can benefit from the solution in the future

                          1 Reply Last reply
                          1
                          • P Offline
                            P Offline
                            patrickkidd
                            wrote on last edited by
                            #14

                            So it seems that writing tests can be quite a minefield, as I expected. For example, I am trying to test editing cells in my tableview and itemdelegate subclasses. As suggested earlier in this thread, mouse double-clicks on an editable cell do not open the editor. Only calling view->openPersistentEditor() works. Fair enough.

                            But my delegate returns a QComboBox for the cell I am testing, and when I call cb->setCurrentIndex() the test crashes in QMetaObject::activate() called from QComboBox::setCurrentIndex(). I can't debug this because I am using python via PyQt5.

                            I've looked in the qt tests for qitemdelegate, qabstractitemview, and qtableview and haven't found any tricks for interacting with these widgets. These tests take a lot of brain power to read, so it is possible that I am missing something.

                            What gives? Is this as hard as it seems?

                            https://alaskafamilysystems.com/

                            1 Reply Last reply
                            0

                            • Login

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