function main()
{
// Register squish_dir/examples/qt/addressbook
// for this example code:
startApplication("addressbook");
// This will fail, unless you create a new
// address book and add a single entry to it,
// but it demonstrates how to use this
// function:
if (!waitForPropertyValue({"type": "QTableWidget", "visible": "1"}, "rowCount", 1, 20000)) {
test.fail("Property did not have the expected value");
} else {
test.pass("Property had the expected value");
}
}
/**
* Needed because Javascript string representation of dictonaries is [Object object] and can not be used for waitFor
**/
function objToString (obj) {
var values = [];
for (var p in obj) {
if (Object.prototype.hasOwnProperty.call(obj, p)) {
values.push(`"${p}":"${obj[p]}"`);
}
}
return `\{${values.join(", ")}\}`;
}
/**
* Waits for property value of an already existing object
**/
function waitForPropertyValue(objectName, propertyName, expectedValue, timeoutInMilliseconds)
{
var condition = `findObject(${objToString(objectName)}).${propertyName}.toString()==expectedValue.toString()`;
return waitFor(condition, timeoutInMilliseconds);
}