aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-10-29 15:50:39 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-11-02 15:23:50 +0000
commit497ac61380d4b6ebfef88923131f61d648857943 (patch)
tree90f8cb1c4de949ffacedac5c23427508814d1b3b /tests/auto/controls
parent2ee0e8770bf43182aae7fd4420e7bd986ecdd68e (diff)
Fix StackView::busy and child event filtering
1) renamed busy() to isBusy() to follow the Qt convention :) 2) fixed spurious busyChanged() emissions (it was always emitted on push/replace/pop even when the state didn't change (null transitions) 3) with null transitions, the child event filter was never turned off and therefore StackView "froze" after the first push/replace/pop Change-Id: I07fffa73db5a182865c7b2779641e1f95ed8b30b Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'tests/auto/controls')
-rw-r--r--tests/auto/controls/data/tst_stackview.qml154
1 files changed, 154 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_stackview.qml b/tests/auto/controls/data/tst_stackview.qml
index 22d4cfe3..23eaf317 100644
--- a/tests/auto/controls/data/tst_stackview.qml
+++ b/tests/auto/controls/data/tst_stackview.qml
@@ -87,18 +87,63 @@ TestCase {
control.destroy()
}
+ SignalSpy {
+ id: busySpy
+ signalName: "busyChanged"
+ }
+
function test_busy() {
var control = stackView.createObject(testCase)
verify(control)
compare(control.busy, false)
+
+ var busyCount = 0
+ busySpy.target = control
+ verify(busySpy.valid)
+
control.push(component)
compare(control.busy, false)
+ compare(busySpy.count, busyCount)
+
control.push(component)
compare(control.busy, true)
+ compare(busySpy.count, ++busyCount)
+ tryCompare(control, "busy", false)
+ compare(busySpy.count, ++busyCount)
+
+ control.replace(component)
+ compare(control.busy, true)
+ compare(busySpy.count, ++busyCount)
tryCompare(control, "busy", false)
+ compare(busySpy.count, ++busyCount)
+
control.pop()
compare(control.busy, true)
+ compare(busySpy.count, ++busyCount)
tryCompare(control, "busy", false)
+ compare(busySpy.count, ++busyCount)
+
+ control.pushEnter = null
+ control.pushExit = null
+
+ control.push(component)
+ compare(control.busy, false)
+ compare(busySpy.count, busyCount)
+
+ control.replaceEnter = null
+ control.replaceExit = null
+
+ control.replace(component)
+ compare(control.busy, false)
+ compare(busySpy.count, busyCount)
+
+ control.popEnter = null
+ control.popExit = null
+
+ control.pop()
+ compare(control.busy, false)
+ compare(busySpy.count, busyCount)
+
control.destroy()
}
@@ -590,4 +635,113 @@ TestCase {
control.destroy()
}
+
+ Component {
+ id: testButton
+ Button {
+ property int clicks: 0
+ onClicked: ++clicks
+ }
+ }
+
+ function test_interaction() {
+ var control = stackView.createObject(testCase, {initialItem: testButton, width: testCase.width, height: testCase.height})
+ verify(control)
+
+ var firstButton = control.currentItem
+ verify(firstButton)
+
+ var firstClicks = 0
+ var secondClicks = 0
+ var thirdClicks = 0
+
+ // push - default transition
+ var secondButton = control.push(testButton)
+ compare(control.busy, true)
+ mouseClick(firstButton) // filtered while busy
+ mouseClick(secondButton) // filtered while busy
+ compare(firstButton.clicks, firstClicks)
+ compare(secondButton.clicks, secondClicks)
+ tryCompare(control, "busy", false)
+ mouseClick(secondButton)
+ compare(secondButton.clicks, ++secondClicks)
+
+ // replace - default transition
+ var thirdButton = control.replace(testButton)
+ compare(control.busy, true)
+ mouseClick(secondButton) // filtered while busy
+ mouseClick(thirdButton) // filtered while busy
+ compare(secondButton.clicks, secondClicks)
+ compare(thirdButton.clicks, thirdClicks)
+ tryCompare(control, "busy", false)
+ secondButton = null
+ secondClicks = 0
+ mouseClick(thirdButton)
+ compare(thirdButton.clicks, ++thirdClicks)
+
+ // pop - default transition
+ control.pop()
+ compare(control.busy, true)
+ mouseClick(firstButton) // filtered while busy
+ mouseClick(thirdButton) // filtered while busy
+ compare(firstButton.clicks, firstClicks)
+ compare(thirdButton.clicks, thirdClicks)
+ tryCompare(control, "busy", false)
+ thirdButton = null
+ thirdClicks = 0
+ mouseClick(firstButton)
+ compare(firstButton.clicks, ++firstClicks)
+
+ // push - immediate operation
+ secondButton = control.push(testButton, StackView.Immediate)
+ compare(control.busy, false)
+ mouseClick(secondButton)
+ compare(secondButton.clicks, ++secondClicks)
+
+ // replace - immediate operation
+ thirdButton = control.replace(testButton, StackView.Immediate)
+ compare(control.busy, false)
+ secondButton = null
+ secondClicks = 0
+ mouseClick(thirdButton)
+ compare(thirdButton.clicks, ++thirdClicks)
+
+ // pop - immediate operation
+ control.pop(StackView.Immediate)
+ compare(control.busy, false)
+ thirdButton = null
+ thirdClicks = 0
+ mouseClick(firstButton)
+ compare(firstButton.clicks, ++firstClicks)
+
+ // push - null transition
+ control.pushEnter = null
+ control.pushExit = null
+ secondButton = control.push(testButton)
+ compare(control.busy, false)
+ mouseClick(secondButton)
+ compare(secondButton.clicks, ++secondClicks)
+
+ // replace - null transition
+ control.replaceEnter = null
+ control.replaceExit = null
+ thirdButton = control.replace(testButton)
+ compare(control.busy, false)
+ secondButton = null
+ secondClicks = 0
+ mouseClick(thirdButton)
+ compare(thirdButton.clicks, ++thirdClicks)
+
+ // pop - null transition
+ control.popEnter = null
+ control.popExit = null
+ control.pop()
+ compare(control.busy, false)
+ thirdButton = null
+ thirdClicks = 0
+ mouseClick(firstButton)
+ compare(firstButton.clicks, ++firstClicks)
+
+ control.destroy()
+ }
}