dotherside/test/testQDeclarative.qml

42 lines
1010 B
QML
Raw Normal View History

2016-06-21 21:15:58 +00:00
import QtQuick 2.3
import MockModule 1.0
Item {
id: testCase
objectName: "testCase"
Component {
id: mockQObjectComponent
MockQObject {}
}
2016-06-21 21:48:57 +00:00
function testMockQObject(testObject) {
2016-06-21 21:15:58 +00:00
if (!testObject)
return false
2016-06-21 21:48:57 +00:00
if (testObject.name !== "foo")
2016-06-21 21:15:58 +00:00
return false
var nameChangedEmitted = false
testObject.nameChanged.connect(function(name){nameChangedEmitted = name === "bar"});
testObject.name = "bar"
2016-06-21 21:48:57 +00:00
return nameChangedEmitted && testObject.name === "bar"
}
function testQmlRegisterType() {
var testObject = mockQObjectComponent.createObject(testCase, {"name":"foo"})
var result = testMockQObject(testObject)
if (testObject)
2016-06-21 21:15:58 +00:00
testObject.destroy()
2016-06-21 21:48:57 +00:00
return result
}
2016-06-21 21:15:58 +00:00
2016-06-21 21:48:57 +00:00
function testQmlRegisterSingletonType() {
var testObject = MockQObjectSingleton
MockQObjectSingleton.name = "foo"
return testMockQObject(testObject)
2016-06-21 21:15:58 +00:00
}
}