diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-10-07 14:51:51 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-10-07 14:34:36 +0000 |
commit | c2b7e55af43518ae1898eddf8611ef617149ca8a (patch) | |
tree | 58707d28d0c8b203b02c0c69507e67498971c665 /tests/auto/controls/data/tst_spinbox.qml | |
parent | bd1080e6a1c78bc65d01f5504bec82ad971d866f (diff) |
auto tests: prefer creating signal spies locally where needed
It is tedious to always add new static SignalSpy instances for each
tested signal. Just create signal spies locally in the same place where
they are used. This makes it much more convenient to create more signal
spies to achieve better coverage. This practice has been already used
in newly written tests.
Change-Id: I7f56c4b3cea0c55c34b85254f69a88ec73b8607f
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/controls/data/tst_spinbox.qml')
-rw-r--r-- | tests/auto/controls/data/tst_spinbox.qml | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index b370a05f..a62128d2 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -50,14 +50,9 @@ TestCase { when: windowShown name: "SpinBox" - SignalSpy{ - id: upPressedSpy - signalName: "pressedChanged" - } - - SignalSpy{ - id: downPressedSpy - signalName: "pressedChanged" + Component { + id: signalSpy + SignalSpy { } } Component { @@ -65,20 +60,6 @@ TestCase { SpinBox { } } - function init() { - verify(!upPressedSpy.target) - compare(upPressedSpy.count, 0) - verify(!downPressedSpy.target) - compare(downPressedSpy.count, 0) - } - - function cleanup() { - upPressedSpy.target = null - upPressedSpy.clear() - downPressedSpy.target = null - downPressedSpy.clear() - } - function test_defaults() { var control = spinBox.createObject(testCase) verify(control) @@ -190,9 +171,12 @@ TestCase { var control = spinBox.createObject(testCase, {stepSize: 50}) verify(control) - upPressedSpy.target = control.up + var upPressedSpy = signalSpy.createObject(control, {target: control.up, signalName: "pressedChanged"}) verify(upPressedSpy.valid) + var downPressedSpy = signalSpy.createObject(control, {target: control.down, signalName: "pressedChanged"}) + verify(downPressedSpy.valid) + mousePress(control.up.indicator) compare(upPressedSpy.count, 1) compare(control.up.pressed, true) @@ -225,9 +209,6 @@ TestCase { compare(control.down.pressed, false) compare(control.value, control.to) - downPressedSpy.target = control.down - verify(downPressedSpy.valid) - control.value = 50; mousePress(control.down.indicator) compare(downPressedSpy.count, 1) @@ -271,10 +252,10 @@ TestCase { var upPressedCount = 0 var downPressedCount = 0 - upPressedSpy.target = control.up + var upPressedSpy = signalSpy.createObject(control, {target: control.up, signalName: "pressedChanged"}) verify(upPressedSpy.valid) - downPressedSpy.target = control.down + var downPressedSpy = signalSpy.createObject(control, {target: control.down, signalName: "pressedChanged"}) verify(downPressedSpy.valid) control.forceActiveFocus() |