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

QtQuickTest: a test case with "when: windowShown" issues a warning on Windows in subsequent test cases

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.2.1
    • Testing: QuickTest
    • None
    • Windows

    Description

      When running a test case after a test case that has the when-property set to windowShown, you get the following warning on Windows unless the width of the component under test is greater than 115px:

      QWARN : qmltestrunner::UnknownTestFunc() QWindowsWindow::setGeometry: Unable to set geometry <width < 116>x<some height>+66+110 on QQuickView/<some_test_file>. Resulting geometry: 116x<some height>+66+110 (frame: 8, 30, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 0x0, maximum size: 16777215x16777215).

      See the following example:

      // tst_data.qml
      import QtTest 1.0
      
      TestCase {
          name: "data"
      
          function test_data_only() {
              compare(1, 1);
          }
      }
      
      // tst_rectangle.qml
      import QtQuick 2.2
      import QtTest 1.0
      
      Item {
          Rectangle {
              id: rect
              color: "#ff0000"
          }
      
          TestCase {
              name: "rectangle"
      
              function test_rect_color() {
                  compare(rect.color, "#ff0000");
              }
          }
      }
      
      // tst_window_shown.qml
      import QtQuick 2.2
      import QtTest 1.0
      
      Item {
          width: 5
          height: 5
      
          MouseArea {
              id: mouseArea
              property string message: "not clicked"
              anchors.fill: parent
              onClicked: {
                  mouseArea.message = "clicked"
              }
          }
      
          TestCase {
              name: "window_shown"
              when: windowShown
      
              function test_mouse_interaction() {
                  compare(mouseArea.message, "not clicked");
                  mouseClick(mouseArea, mouseArea.width / 2, mouseArea.height / 2);
                  compare(mouseArea.message, "clicked");
              }
          }
      
      }
      

      Now, run them in different combinations and different order:

      1) data -> rectangle -> window_shown: no warning
      2) rectangle -> data: no warning
      3) window_shown -> data: warning!
      4) window_shown -> rectangle: warning!
      5) window_shown -> window_shown: warning!

      So, any test case that is not within an Item wider than 115px and run after tst_window_shown.qml leads to the warning. This seems to be because the window is reused and tried to be resized.

      Especially the combination 3) from above is confusing because the second test is pure data, i.e. without relation to any visual component.

      Please see attached zip to reproduce this conveniently.

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            mlitauer Martin Litauer
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes