-
Bug
-
Resolution: Invalid
-
P1: Critical
-
None
-
6.6
I tested the below QML code, and mouseClick never gets onClicked triggered
import QtQuick 2.15 import QtTest 1.0 import QtQuick.Controls TestCase { name: "MyTestcase" Button { id: button onClicked: console.log("onClicked") } MouseArea { id: mouseArea width: 100 height: 100 onClicked: console.log("onClicked") } SignalSpy { id: spy target: mouseArea signalName: "onClicked" } function initTestCase() { } function cleanupTestCase() { } function test_case1() { mouseClick(button) mouseClick(mouseArea) spy.wait() } }
or
TestCase {
name: "MyTestcase"
when: windowShown
Window {
id: window
Component {
id: button
MouseArea {
onClicked: console.log("onClicked")
}
}
}
function test_case1() {
var item = createTemporaryObject(button, window);
mouseClick(item);
}
}
to get the above code to work need to fit these hidden requirements of mouseClick:
- for Button and MouseArea, need a parent Window (set testcase.when: windowShown is not mandatory)
- for MouseArea, it must have a valid size, width, height need to bigger than zero