I want to test complex qml gui using QuickTest framewrok. The C++ portion of the code is very short:
#include <QtQuickTest/quicktest.h>
QUICK_TEST_MAIN(QmlFormToBeTested)
The qml document looks like this:
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtGraphicalEffects 1.0
import CalcCritRangeSetup 1.0
import CfgEnableTable 1.0
import PrecisionHelper 1.0
import UnitsSetupTable 1.0
Rectangle
{
id: criticalRanges
width: sys.width
height: sys.height
color: sys.screen_background_color
property int lowEntryError: 0
property int highEntryError: 0
property string enableState: ""
property variant selectedInput: null
property variant selectedRectangle: null
property int selectedType: -1
property bool changeMade: false
property bool canEdit: false
property bool showKeyboard: false
property string selectedParameter: ""
...
The following import modules are from database models that are needed for the view:
CalcCritRangeSetup 1.0
CfgEnableTable 1.0
PrecisionHelper 1.0
UnitsSetupTable 1.0
In other words, the qml file is coupled with other c++ code. In real application, the main c++ will initialized the database, and register these database model and use them in qml code, and all works fine.
I try to use the QUICK_TEST_MAIN(QmlFormToBeTested) to test the qml file. As the main is generated by macro, and can't use c++ code to register model for qml use. So was wondering if anyone has suggestions for this ? Is it ok to generate a QmlGuiInit Plugin that include all the initialization and registration of the models? or perhaps other suggestions for this kind of complex qml gui unit test?
Thanks in advance,
Alex




Reply With Quote
Bookmarks