tst_toolbutton: 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: Ie6e050fdd77b1711350ecc00f05d2e6bcd979fc5 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
This commit is contained in:
parent
95bc6a1f3e
commit
377d11bd65
|
@ -1,6 +1,6 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2015 The Qt Company Ltd.
|
** Copyright (C) 2016 The Qt Company Ltd.
|
||||||
** Contact: http://www.qt.io/licensing/
|
** Contact: http://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of the test suite of the Qt Toolkit.
|
** This file is part of the test suite of the Qt Toolkit.
|
||||||
|
@ -61,7 +61,7 @@ TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_text() {
|
function test_text() {
|
||||||
var control = toolButton.createObject(testCase)
|
var control = createTemporaryObject(toolButton, testCase)
|
||||||
verify(control)
|
verify(control)
|
||||||
|
|
||||||
compare(control.text, "")
|
compare(control.text, "")
|
||||||
|
@ -69,12 +69,10 @@ TestCase {
|
||||||
compare(control.text, "ToolButton")
|
compare(control.text, "ToolButton")
|
||||||
control.text = ""
|
control.text = ""
|
||||||
compare(control.text, "")
|
compare(control.text, "")
|
||||||
|
|
||||||
control.destroy()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_mouse() {
|
function test_mouse() {
|
||||||
var control = toolButton.createObject(testCase)
|
var control = createTemporaryObject(toolButton, testCase)
|
||||||
verify(control)
|
verify(control)
|
||||||
|
|
||||||
var pressedSpy = signalSpy.createObject(control, {target: control, signalName: "pressedChanged"})
|
var pressedSpy = signalSpy.createObject(control, {target: control, signalName: "pressedChanged"})
|
||||||
|
@ -140,12 +138,10 @@ TestCase {
|
||||||
compare(downSpy.count, 6)
|
compare(downSpy.count, 6)
|
||||||
compare(control.pressed, false)
|
compare(control.pressed, false)
|
||||||
compare(control.down, false)
|
compare(control.down, false)
|
||||||
|
|
||||||
control.destroy()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_keys() {
|
function test_keys() {
|
||||||
var control = toolButton.createObject(testCase)
|
var control = createTemporaryObject(toolButton, testCase)
|
||||||
verify(control)
|
verify(control)
|
||||||
|
|
||||||
var clickedSpy = signalSpy.createObject(control, {target: control, signalName: "clicked"})
|
var clickedSpy = signalSpy.createObject(control, {target: control, signalName: "clicked"})
|
||||||
|
@ -168,14 +164,11 @@ TestCase {
|
||||||
keyClick(keys[i])
|
keyClick(keys[i])
|
||||||
compare(clickedSpy.count, 2)
|
compare(clickedSpy.count, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
control.destroy()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_baseline() {
|
function test_baseline() {
|
||||||
var control = toolButton.createObject(testCase)
|
var control = createTemporaryObject(toolButton, testCase)
|
||||||
verify(control)
|
verify(control)
|
||||||
compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset)
|
compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset)
|
||||||
control.destroy()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue