I've seen many of those tests in the SDK and I personally think this is quite useless. It only tests if the component actually compiles (ok, better than nothing) and if there actually is a property size sourceSize which is not readonly. That's it. But if the sourceSize is actually used by image? This is not tested. Here's an example how to check that:
// Put this into some helper.js, or TestCaseBase class to inherit from as you're gonna need this in every test as of now. In unity we have a UnityTestCase which inherits a TestCase and adds lots of useful helpers. Feel free to copy that too.
// Find an object with the given name in the children tree of "obj"
function findChild(obj,objectName) {
var childs = new Array(0); childs.push(obj)
while (childs.length > 0) {
if (childs[0].objectName == objectName) { return childs[0]
}
for (var i in childs[0].children) { childs.push(childs[0].children[i])
} childs.splice(0, 1);
}
return undefined;
}
// Now we have a way to look inside the components. Let's do the test using this:
Edit CrossFadeImage.qml and add "objectName" properties to image1 and image2, like this:
108 + "../../ ../examples/ ubuntu- ui-toolkit- gallery/ demo_image. jpg"); crossFadeImage. sourceSize. width, 640, "Source width incorrectly initialized."); crossFadeImage. sourceSize. height, 427, "Source height incorrectly initialized."); sourceSize. width = 100; sourceSize. height = 101; crossFadeImage. sourceSize. width, 100, "Source width incorrectly updated."); crossFadeImage. sourceSize. height, 101, "Source height incorrectly updated.");
109 + function test_sourceSize() {
110 + loadImage(
111 + compare(
112 + compare(
113 + crossFadeImage.
114 + crossFadeImage.
115 + compare(
116 + compare(
117 + waitForAnimation();
118 + cleanupTest();
119 + }
I've seen many of those tests in the SDK and I personally think this is quite useless. It only tests if the component actually compiles (ok, better than nothing) and if there actually is a property size sourceSize which is not readonly. That's it. But if the sourceSize is actually used by image? This is not tested. Here's an example how to check that:
// Put this into some helper.js, or TestCaseBase class to inherit from as you're gonna need this in every test as of now. In unity we have a UnityTestCase which inherits a TestCase and adds lots of useful helpers. Feel free to copy that too.
// Find an object with the given name in the children tree of "obj" obj,objectName) {
childs. push(obj) 0].objectName == objectName) {
return childs[0]
childs. push(childs[ 0].children[ i])
childs. splice( 0, 1);
function findChild(
var childs = new Array(0);
while (childs.length > 0) {
if (childs[
}
for (var i in childs[0].children) {
}
}
return undefined;
}
// Now we have a way to look inside the components. Let's do the test using this:
Edit CrossFadeImage.qml and add "objectName" properties to image1 and image2, like this:
Image {
id: image1
objectName: "image1"
...
}
And now the test
function test_sourceSize() { "../../ ../examples/ ubuntu- ui-toolkit- gallery/ demo_image. jpg"); crossFadeImage. sourceSize. width, 640, "Source width incorrectly initialized."); crossFadeImage. sourceSize. height, 427, "Source height incorrectly initialized."); e.sourceSize. width = 100; e.sourceSize. height = 101;
loadImage(
compare(
compare(
crossFadeImag
crossFadeImag
var image1 = findChild( crossFadeImage, "image1"); crossFadeImage, "image2");
var image2 = findChild(
compare( image1. sourceSize. width, 100, "Source width incorrectly updated."); image1. sourceSize. height, 101, "Source height incorrectly updated.");
compare(
compare( image2. sourceSize. width, 100, "Source width incorrectly updated."); image2. sourceSize. height, 101, "Source height incorrectly updated.");
compare(
waitForAnimat ion();
cleanupTest();
}