Storybook: TestUtils singleton added
This commit is contained in:
parent
8c2d2115b0
commit
bb2eeaa79d
|
@ -0,0 +1,42 @@
|
|||
pragma Singleton
|
||||
|
||||
import QtQuick 2.15
|
||||
|
||||
import QtQml 2.15
|
||||
|
||||
QtObject {
|
||||
function findTextItem(root, text) {
|
||||
for (let i = 0; i < root.children.length; i++) {
|
||||
const c = root.children[i]
|
||||
|
||||
if (c instanceof Text && c.text === text)
|
||||
return c
|
||||
|
||||
const sub = findTextItem(c, text)
|
||||
|
||||
if (sub)
|
||||
return sub
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
function findByType(root, type) {
|
||||
const children = []
|
||||
|
||||
for (let i = 0; i < root.children.length; i++)
|
||||
children.push(root.children[i])
|
||||
|
||||
while (children.length > 0) {
|
||||
const c = children.shift()
|
||||
|
||||
if (c instanceof type)
|
||||
return c
|
||||
|
||||
for (let i = 0; i < c.children.length; i++)
|
||||
children.push(c.children[i])
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
|
@ -33,3 +33,4 @@ TestRunnerControls 1.0 TestRunnerControls.qml
|
|||
singleton FigmaUtils 1.0 FigmaUtils.qml
|
||||
singleton InspectionUtils 1.0 InspectionUtils.qml
|
||||
singleton StorybookUtils 1.0 StorybookUtils.qml
|
||||
singleton TestUtils 1.0 TestUtils.qml
|
||||
|
|
Loading…
Reference in New Issue