framework and basic example of qml tests
This commit is contained in:
parent
9d9ecb3cc0
commit
a00f1b081a
1 changed files with 67 additions and 0 deletions
67
src/test/test_service_item_model.qml
Normal file
67
src/test/test_service_item_model.qml
Normal file
|
@ -0,0 +1,67 @@
|
|||
import QtQuick 2.12
|
||||
import QtTest 1.12
|
||||
|
||||
import org.presenter 1.0
|
||||
|
||||
TestCase {
|
||||
name: "MyObjectTests"
|
||||
|
||||
Component {
|
||||
id: serviceItemModel
|
||||
|
||||
ServiceItemModel {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: slideModel
|
||||
|
||||
SlideModel {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function test_increment() {
|
||||
const myObject = createTemporaryObject(componentMyObject, null, {
|
||||
number: 1
|
||||
});
|
||||
compare(myObject.number, 1);
|
||||
myObject.incrementNumber();
|
||||
compare(myObject.number, 2);
|
||||
}
|
||||
|
||||
function test_number() {
|
||||
const myObject = createTemporaryObject(componentMyObject, null, {
|
||||
number: 1,
|
||||
});
|
||||
const spy = createTemporaryObject(componentSpy, null, {
|
||||
signalName: "numberChanged",
|
||||
target: myObject,
|
||||
});
|
||||
compare(myObject.number, 1);
|
||||
compare(spy.count, 0);
|
||||
|
||||
myObject.number = 2;
|
||||
|
||||
compare(myObject.number, 2);
|
||||
compare(spy.count, 1);
|
||||
}
|
||||
|
||||
function test_string() {
|
||||
const myObject = createTemporaryObject(componentMyObject, null, {
|
||||
string: "hello",
|
||||
});
|
||||
const spy = createTemporaryObject(componentSpy, null, {
|
||||
signalName: "stringChanged",
|
||||
target: myObject,
|
||||
});
|
||||
compare(myObject.string, "hello");
|
||||
compare(spy.count, 0);
|
||||
|
||||
myObject.string = "world";
|
||||
|
||||
compare(myObject.string, "world");
|
||||
compare(spy.count, 1);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue