Commit 3a8bf11f authored by Ronan Abhamon's avatar Ronan Abhamon

feat(InvertedMouseArea.spec.qml): add fixed tests (outside/inside clicks)

parent 47c733bb
......@@ -32,18 +32,17 @@ Rectangle {
id: spy
signalName: 'pressed'
target: invertedMouseArea
}
TestCase {
when: windowShown
function test_randomInsideMouseArea () {
var failFun = function () {
fail('`pressed` signal was emitted.')
}
invertedMouseArea.pressed.connect(failFun)
function init () {
spy.clear()
}
function test_randomClickInsideMouseArea () {
Utils.times(100, function () {
var x = Math.floor(Utils.genRandomNumber(item.x, item.x + width))
var y = Math.floor(Utils.genRandomNumber(item.y, item.y + height))
......@@ -52,12 +51,12 @@ Rectangle {
})
wait(100)
invertedMouseArea.pressed.disconnect(failFun)
compare(spy.count, 0, '`pressed` signal was emitted')
}
function test_randomOutsideMouseArea () {
spy.target = invertedMouseArea
// ---------------------------------------------------------------
function test_randomClickOutsideMouseArea () {
Utils.times(50, function () {
var x = Math.floor(Utils.genRandomNumberBetweenIntervals([
[ 0, item.x ], [ item.x + item.width, root.width ]
......@@ -80,5 +79,39 @@ Rectangle {
spy.wait(100)
})
}
// ---------------------------------------------------------------
function test_clickInsideMouseArea_data () {
return [
{ x: item.x, y: item.y },
{ x: item.x + item.width - 1, y: item.y },
{ x: item.x, y: item.y + item.height - 1},
{ x: item.x + item.width - 1, y: item.y + item.height - 1 },
{ } // item center.
]
}
function test_clickInsideMouseArea (data) {
mouseClick(root, data.x, data.y)
wait(100)
compare(spy.count, 0, '`pressed` signal was emitted')
}
// ---------------------------------------------------------------
function test_clickOutsideMouseArea_data () {
return [
{ x: item.x - 1, y: item.y - 1},
{ x: item.x + item.width, y: item.y },
{ x: item.x, y: item.y + item.height },
{ x: item.x + item.width, y: item.y + item.height }
]
}
function test_clickOutsideMouseArea (data) {
mouseClick(root, data.x, data.y)
spy.wait(100)
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment