Unit tests fail where mouseClick() is used to simulate a click event on a MouseArea which is a descendant of a TextField

Bug #1483279 reported by Olivier Tilloy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ubuntu-ui-toolkit (Ubuntu)
New
Undecided
Unassigned

Bug Description

This appears to be a regression in version 1.3 of the UITK.

The browser has an AddressBar component which contains a TextField, and the secondaryItem for this TextField is a MouseArea (for toggling the bookmarked status of the current address). This component is unit tested, and there is a test that simulates a click on the secondaryItem to verify that the bookmarked status is correctly toggled.

This test worked with version 1.2 of the UITK, but fails when I update the import of Ubuntu.Components to 1.3.
It appears that the TextField itself intercepts the simulated mouse click event, thus getting active focus.

Note that the component works as expected when used in an app by a normal user manipulating a mouse (i.e. the secondaryItem can be clicked and that toggles the bookmark status as expected). It’s only the unit tests that are failing.

I’m suspecting that the way QtTest simulates a mouse click event doesn’t play well with Ubuntu.Mouse.forwardTo, although I’m not really sure how and why.

Related branches

Revision history for this message
Olivier Tilloy (osomon) wrote :

I’m attaching a simple standalone reproducer. Observe the issue by running it like that:

    qmltestrunner -input tst_test.qml

Revision history for this message
Olivier Tilloy (osomon) wrote :

Note that that the enabled-ness (or visibility) of the MouseArea plays a key role in the issue: if 'enabled' (or 'visible') is set to !textField.activeFocus, the issue occurs. If always visible/enabled, the issue doesn’t occur.

Revision history for this message
Zsombor Egri (zsombi) wrote :

There is no difference between 1.2 and 1.3 TextField logic. QtTest uses the item in mouseClick() to calculate the position relative to the window, and will send the event to the window. So mouse forwarding will work as usual. At least theoretically.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.