/ base / WindowTestCase.qml
WindowTestCase.qml
 1  import QtQuick 2.14
 2  import QtTest 1.14
 3  
 4  import QtQuick.Window 2.14
 5  
 6  TestCase {
 7      id: root
 8  
 9      readonly property Window window: baseWindow
10      readonly property Item windowContent: contentWindow
11  
12      Window {
13          id: baseWindow
14          width: 800
15          height: 600
16  
17          Item {
18              id: contentWindow
19              anchors.fill: parent
20          }
21  
22          visible: true
23      }
24  
25      property Helpers __helpers: Helpers {}
26  
27      function getObjectByObjectName(parent, objectName) {
28          var result = __helpers.getObjectByObjectName(parent, objectName)
29          verify(result, "Method getObjectByObjectName can't find object with name:" + objectName + " in parent:" + parent.toString())
30          return result
31      }
32  
33      function clickOnButton(item) {
34          verify(item, "item is null")
35          verify((item.width !== 0 && item.height !== 0) ||
36                 (item.implicitWidth !== 0 && item.implicitHeight !== 0) , "item has zero sizes")
37          verify(item.visible, "item is invisibble")
38  
39          if (item.width !== 0 && item.height !== 0) {
40              mouseClick(item, item.width / 2, item.height / 2, Qt.LeftButton)
41          } else {
42              mouseClick(item, item.implicitWidth / 2, item.implicitHeight / 2, Qt.LeftButton)
43          }
44      }
45  
46      function initTestCase() {
47          window.show()
48      }
49  
50      function cleanupTestCase() {
51          window.close()
52      }
53  }