Unit test for QML
-
I have written a couple of unit tests to test my QMLs already - passing values to QML, call functions and reading properties.
@
int argc(5);
char** argv = new char *[5];
argv[0] = "";
argv[1] = "";
argv[2] = "";
argv[3] = "";
argv[4] = "";
QGuiApplication app(argc, argv);
QQmlEngine engine;QQmlComponent component(&engine, QUrl("qrc:/myTest/Test.qml")); m_object = component.create(); QMetaObject::invokeMethod(m_object, "myMethod", Q_ARG(QVariant, "test test")); QString str = QQmlProperty(m_object, "myString").read().toString();
@
This is working perfectly fine as long as I do not call any methods on the Canvas which use the context2d.
@
import QtQuick 2.0Item {
property string myString
Canvas
{
id: canvas
}function myMethod(str) { myString = str }
}
@If I call methods on the context2d, I get the following message:
Unable to use getContext() at this time, please wait for available: trueI guess I need to make the canvas visible to test it? Are there any suggestions of how to do that or how I can "fake" the availability?