Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-92196

Discrepancy between user input and simulated test input when clicking shift key

    XMLWordPrintable

    Details

      Description

      Run the attached test and you'll see this output:

      QDEBUG : tst_Untitled::testCase1() Key_Shift ("1000020", "") pressed with modifiersQFlags<Qt::KeyboardModifier>(ShiftModifier)
      QDEBUG : tst_Untitled::testCase1() Key_Shift ("1000020", "") released with modifiersQFlags<Qt::KeyboardModifier>(ShiftModifier)
      

      Then make the following changes

          QTest::qWait(1000);
      
      //    QTest::keyPress(window, Qt::Key_Shift);
      //    QTest::keyRelease(window, Qt::Key_Shift);
      

      and click the shift key once before the test finishes, and you'll see this output:

      QDEBUG : tst_Untitled::testCase1() Key_Shift ("1000020", "") pressed with modifiersQFlags<Qt::KeyboardModifier>(ShiftModifier)
      QDEBUG : tst_Untitled::testCase1() Key_Shift ("1000020", "") released with modifiersQFlags<Qt::KeyboardModifier>(NoModifier)
      

      This difference (along with the fact that shift event handling/behaviour doesn't seem to be documented) makes it impossible to test shift events in an application: if I handle modifiers one way, the test will fail, and if I do it the other way, the actual application won't work as expected.

      The only documentation I can find is https://doc.qt.io/qt-5/qkeyevent.html#modifiers, and it says:

      Returns the keyboard modifier flags that existed immediately after the event occurred.

      So is Qt Test wrong?

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              Assignee:
              ablasche Alex Blasche
              Reporter:
              mitch_curtis Mitch Curtis
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:

                  Gerrit Reviews

                  There are no open Gerrit changes