diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2016-12-20 11:32:44 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2016-12-20 11:59:21 +0000 |
commit | bf7719bd1952cd9af83f4e01838d23f11db64748 (patch) | |
tree | a554d0ea3f76b324c652fcc6514c11ab5e4a1d83 /tests/auto | |
parent | 4d17371fa9a82b331681754b237e4cee2a62496d (diff) |
tst_switch: use TestCase's new createTemporaryObject functions
This ensures that the appropriate objects are destroyed at the end of
each test function, even if the test fails.
Change-Id: I537581612f279e527a0304800bbe153b372e5c12
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/controls/data/tst_switch.qml | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/tests/auto/controls/data/tst_switch.qml b/tests/auto/controls/data/tst_switch.qml index 4c2147f8..51c58603 100644 --- a/tests/auto/controls/data/tst_switch.qml +++ b/tests/auto/controls/data/tst_switch.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -63,7 +63,7 @@ TestCase { } function test_text() { - var control = swtch.createObject(testCase) + var control = createTemporaryObject(swtch, testCase) verify(control) compare(control.text, "") @@ -71,12 +71,10 @@ TestCase { compare(control.text, "Switch") control.text = "" compare(control.text, "") - - control.destroy() } function test_checked() { - var control = swtch.createObject(testCase) + var control = createTemporaryObject(swtch, testCase) verify(control) compare(control.checked, false) @@ -91,8 +89,6 @@ TestCase { control.checked = false compare(control.checked, false) verify(spy.success) - - control.destroy() } function test_pressed_data() { @@ -103,7 +99,7 @@ TestCase { } function test_pressed(data) { - var control = swtch.createObject(testCase, {padding: 10}) + var control = createTemporaryObject(swtch, testCase, {padding: 10}) verify(control) // stays pressed when dragged outside @@ -114,12 +110,10 @@ TestCase { compare(control.pressed, true) mouseRelease(control, -1, control.height / 2, Qt.LeftButton) compare(control.pressed, false) - - control.destroy() } function test_mouse() { - var control = swtch.createObject(testCase) + var control = createTemporaryObject(swtch, testCase) verify(control) // check @@ -200,12 +194,10 @@ TestCase { compare(control.checked, false) compare(control.pressed, false) verify(spy.success) - - control.destroy() } function test_drag() { - var control = swtch.createObject(testCase, {leftPadding: 100, rightPadding: 100}) + var control = createTemporaryObject(swtch, testCase, {leftPadding: 100, rightPadding: 100}) verify(control) var spy = signalSequenceSpy.createObject(control, {target: control}) @@ -307,12 +299,10 @@ TestCase { compare(control.checked, true) compare(control.pressed, false) verify(spy.success) - - control.destroy() } function test_keys() { - var control = swtch.createObject(testCase) + var control = createTemporaryObject(swtch, testCase) verify(control) control.forceActiveFocus() @@ -351,8 +341,6 @@ TestCase { compare(control.checked, false) verify(spy.success) } - - control.destroy() } Component { @@ -364,7 +352,7 @@ TestCase { } function test_binding() { - var container = twoSwitches.createObject(testCase) + var container = createTemporaryObject(twoSwitches, testCase) verify(container) compare(container.sw1.checked, false) @@ -377,25 +365,20 @@ TestCase { container.sw1.checked = false compare(container.sw1.checked, false) compare(container.sw2.checked, false) - - container.destroy() } function test_baseline() { - var control = swtch.createObject(testCase) + var control = createTemporaryObject(swtch, testCase) verify(control) compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset) - control.destroy() } function test_focus() { - var control = swtch.createObject(testCase) + var control = createTemporaryObject(swtch, testCase) verify(control) verify(!control.activeFocus) mouseClick(control.indicator) verify(control.activeFocus) - - control.destroy() } } |