mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-05-07 14:44:01 +00:00
feat(utils.spec.qml): add a test on setTimeout
This commit is contained in:
parent
e30574e07f
commit
cb131ed71f
2 changed files with 39 additions and 1 deletions
|
|
@ -97,7 +97,7 @@ function setTimeout (delay, cb) {
|
|||
}
|
||||
|
||||
function clearTimeout (timer) {
|
||||
timer.destroy() // Not necessary: `timer.stop()`
|
||||
timer.destroy() // Unnecessary call: `timer.stop()`
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -5,7 +5,11 @@ import QtTest 1.1
|
|||
// when tests are executed.
|
||||
import './utils.js' as Utils
|
||||
|
||||
// ===================================================================
|
||||
|
||||
TestCase {
|
||||
id: testCase
|
||||
|
||||
name: 'UtilsTests'
|
||||
|
||||
function test_snakeToCamel_data () {
|
||||
|
|
@ -20,4 +24,38 @@ TestCase {
|
|||
function test_snakeToCamel (data) {
|
||||
compare(Utils.snakeToCamel(data.input), data.output)
|
||||
}
|
||||
|
||||
function test_setTimeoutWithoutParent () {
|
||||
try {
|
||||
Utils.setTimeout(0, function () {
|
||||
fail('`setTimeout` was called without parent.')
|
||||
})
|
||||
} catch (e) {
|
||||
compare(e, 'Error: Qt.createQmlObject(): Missing parent object')
|
||||
}
|
||||
}
|
||||
|
||||
function test_setTimeout_data () {
|
||||
return [
|
||||
{ time: 0 },
|
||||
{ time: 100 }
|
||||
]
|
||||
}
|
||||
|
||||
function test_setTimeout (data) {
|
||||
var failed = true
|
||||
Utils.setTimeout.call(testCase, data.time, function () {
|
||||
failed = false
|
||||
})
|
||||
|
||||
if (!failed) {
|
||||
fail('`setTimeout` callback was called before `wait`')
|
||||
}
|
||||
|
||||
wait(200)
|
||||
|
||||
if (failed) {
|
||||
fail('`setTimeout` failed because callback it was not called in due course')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue