Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
64e5a70b
Commit
64e5a70b
authored
Nov 10, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(Utils): better style
parent
d9b4dff2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
72 deletions
+78
-72
utils.js
tests/ui/scripts/Utils/utils.js
+17
-17
utils.spec.qml
tests/ui/scripts/Utils/utils.spec.qml
+61
-55
No files found.
tests/ui/scripts/Utils/utils.js
View file @
64e5a70b
...
@@ -153,23 +153,6 @@ function openWindow (window, parent, options) {
...
@@ -153,23 +153,6 @@ function openWindow (window, parent, options) {
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// A copy of `Window.setTimeout` from js.
// delay is in milliseconds.
function
setTimeout
(
parent
,
delay
,
cb
)
{
var
timer
=
new
(
function
(
parent
)
{
return
Qt
.
createQmlObject
(
'
import QtQuick 2.7; Timer { }
'
,
parent
)
})(
parent
)
timer
.
interval
=
delay
timer
.
repeat
=
false
timer
.
triggered
.
connect
(
cb
)
timer
.
start
()
return
timer
}
// -------------------------------------------------------------------
// Test if a point is in a item.
// Test if a point is in a item.
//
//
// `source` is the item that generated the point.
// `source` is the item that generated the point.
...
@@ -203,6 +186,23 @@ function qmlTypeof (object, className) {
...
@@ -203,6 +186,23 @@ function qmlTypeof (object, className) {
)
)
}
}
// -------------------------------------------------------------------
// A copy of `Window.setTimeout` from js.
// delay is in milliseconds.
function
setTimeout
(
parent
,
delay
,
cb
)
{
var
timer
=
new
(
function
(
parent
)
{
return
Qt
.
createQmlObject
(
'
import QtQuick 2.7; Timer { }
'
,
parent
)
})(
parent
)
timer
.
interval
=
delay
timer
.
repeat
=
false
timer
.
triggered
.
connect
(
cb
)
timer
.
start
()
return
timer
}
// ===================================================================
// ===================================================================
// GENERIC.
// GENERIC.
// ===================================================================
// ===================================================================
...
...
tests/ui/scripts/Utils/utils.spec.qml
View file @
64e5a70b
...
@@ -10,6 +10,37 @@ import './utils.js' as Utils
...
@@ -10,6 +10,37 @@ import './utils.js' as Utils
TestCase
{
TestCase
{
id
:
testCase
id
:
testCase
// =================================================================
// QML helpers.
// =================================================================
function
test_clearTimeout_data
()
{
return
[
{
time
:
0
},
{
time
:
100
}
]
}
function
test_clearTimeout
(
data
)
{
var
failed
=
false
var
timeout
=
Utils
.
setTimeout
(
testCase
,
data
.
time
,
function
()
{
failed
=
true
})
if
(
failed
)
{
fail
(
'
`setTimeout` callback was called before `wait`.
'
)
}
Utils
.
clearTimeout
(
timeout
)
wait
(
100
)
if
(
failed
)
{
fail
(
'
`setTimeout` callback was called after `wait`.
'
)
}
}
// -----------------------------------------------------------------
// Test only if a confirm dialog can be opened.
// Test only if a confirm dialog can be opened.
// The other tests are launched by `ConfirmDialog.spec.qml`.
// The other tests are launched by `ConfirmDialog.spec.qml`.
function
test_openConfirmDialog
()
{
function
test_openConfirmDialog
()
{
...
@@ -33,6 +64,33 @@ TestCase {
...
@@ -33,6 +64,33 @@ TestCase {
// -----------------------------------------------------------------
// -----------------------------------------------------------------
function
test_qmlTypeof_data
()
{
return
[
{
component
:
'
import QtQuick 2.7; ListModel {}
'
,
result
:
true
,
type
:
'
QQmlListModel
'
},
{
component
:
'
import QtQuick 2.7; ListView {}
'
,
result
:
true
,
type
:
'
QQuickListView
'
},
{
component
:
'
import QtQuick 2.7; MouseArea {}
'
,
result
:
true
,
type
:
'
QQuickMouseArea
'
}
]
}
function
test_qmlTypeof
(
data
)
{
var
object
=
Qt
.
createQmlObject
(
data
.
component
,
testCase
)
verify
(
object
)
compare
(
Utils
.
qmlTypeof
(
object
,
data
.
type
),
data
.
result
)
}
// -----------------------------------------------------------------
function
test_setTimeoutWithoutParent
()
{
function
test_setTimeoutWithoutParent
()
{
try
{
try
{
Utils
.
setTimeout
(
null
,
0
,
function
()
{
Utils
.
setTimeout
(
null
,
0
,
function
()
{
...
@@ -67,61 +125,9 @@ TestCase {
...
@@ -67,61 +125,9 @@ TestCase {
}
}
}
}
// -----------------------------------------------------------------
// =================================================================
// GENERIC.
function
test_clearTimeout_data
()
{
// =================================================================
return
[
{
time
:
0
},
{
time
:
100
}
]
}
function
test_clearTimeout
(
data
)
{
var
failed
=
false
var
timeout
=
Utils
.
setTimeout
(
testCase
,
data
.
time
,
function
()
{
failed
=
true
})
if
(
failed
)
{
fail
(
'
`setTimeout` callback was called before `wait`.
'
)
}
Utils
.
clearTimeout
(
timeout
)
wait
(
100
)
if
(
failed
)
{
fail
(
'
`setTimeout` callback was called after `wait`.
'
)
}
}
// -----------------------------------------------------------------
function
test_qmlTypeof_data
()
{
return
[
{
component
:
'
import QtQuick 2.7; ListModel {}
'
,
result
:
true
,
type
:
'
QQmlListModel
'
},
{
component
:
'
import QtQuick 2.7; ListView {}
'
,
result
:
true
,
type
:
'
QQuickListView
'
},
{
component
:
'
import QtQuick 2.7; MouseArea {}
'
,
result
:
true
,
type
:
'
QQuickMouseArea
'
}
]
}
function
test_qmlTypeof
(
data
)
{
var
object
=
Qt
.
createQmlObject
(
data
.
component
,
testCase
)
verify
(
object
)
compare
(
Utils
.
qmlTypeof
(
object
,
data
.
type
),
data
.
result
)
}
// -----------------------------------------------------------------
function
test_genRandomNumber_data
()
{
function
test_genRandomNumber_data
()
{
return
[
return
[
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment