> > Then I would like to test application logic by sending keypresses and
> > mouseclicks on certain child elements of my application, buttons, inputs
> > etc.
> 
> Another thing you might be interesting in looking at is the visual test 
> infrastructure (note that it's experimental, there are no compatibility 
> guarantees, etc), located in tests/auto/declarative/qmlvisual. It handles 
> interaction by sending events to the scene as a whole (with e.g. the global 
> position information for a mouse event) and letting the scene send the event 
> to the appropriate element.

I've looked at it and I think it's a novel idea and definitely worth
considering. It brings more decoupling of the application code and
testing code which I really like. However, I can't seem to find, that it
has any sort of formal verification, only record and playback of tests,
but I guess that is the price, if you want to have this level of
decoupling.

> 
> > However, since I've instantiated my application in another qml file, the
> > internal id's of main are not accessible, so how do I send a click event
> > to a button for instance?
> > 
> > That was why I wanted to have a getChildById method, so I could actually
> > find the element I wanted and send it whatever event.
> > 
> > The way I've done it now is to enforce setting objectName on all
> > elements that I need to access to and then instead of having
> > getChildById, it's getChildByObjectName, which is just
> > QObject::findChild() wrapped.
> > 
> > My point is that identical id and objectName makes for redundant code,
> > so if there was a way of addressing by id, as done in QML, it would
> > definitely help quell my OCD and make for a more DRY feel of the QML
> > code.
> 
> 
> I agree having to add objectName (or lots of property aliases) to production 
> code simply for testing is not an ideal solution. I'm hesitant about a 
> getChildById() for general QML programming, but it seems to make sense in an 
> auto testing (and accessibility?) context, so maybe we should look for 
> specific solutions there first (addressing e.g. the issues that Alan raised 
> in another thread). 

Alan has a valid point about dynamicly created QML objects,
http://lists.trolltech.com/pipermail/qt-qml/2010-November/001542.html

One solution might be to implicitly append or prepend the index to the
id in those cases, but I'm not sure how that would work though.

/René

_______________________________________________
Qt-qml mailing list
Qt-qml@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-qml

Reply via email to