xpathselect 1.4 sorts Introspection items when it should not

Bug #1259327 reported by Christopher Townsend
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
XPathSelect
Won't Fix
Undecided
Unassigned

Bug Description

We have been getting a number of Unity AP test failures lately particularly in the Switcher tests, but other tests may be affected as well.

After exhaustive debugging, I discovered that introspection items were getting sorting in an order that was different than what our AP tests assume. For example, the icons in the Switcher view are getting sorted based on their id, so the icon list would be in a different order than was actually in the Switcher.

I have found that this code snippet is responsible for this (particularly the sort function, but I don't think having the unique function is good either):
        // remove duplicate nodes by sorting & unique'ing:
        // we could probably do this better, but since start_nodes is
        // typically very small at this stage, I'm not sure it's worth it:
        start_nodes.sort([](Node::Ptr a, Node::Ptr b) -> bool {
            return a->GetId() < b->GetId();
        });
        start_nodes.unique([](Node::Ptr a, Node::Ptr b) -> bool {
            return a->GetId() == b->GetId();
        });

Once I removed that code, the tests began to work as expected again.

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Hi Chris,

Thanks for your report. However, the AP documentation explicitly states that object ordering is not guaranteed. If you want your objects ordered in a particular way, you need to sort them based on some object attribute. The reason is simple: object are in a tree, and most (if not all?) UI toolkits don't guarantee an order between sibling widgets. If Qt and Gtk can't guarantee us a widget order, we can't provide that guarantee to our users.

At the same time, there are good reasons to order the object list by id: it makes several operations in autopilot itself much faster.

So, I'm not sure of the exact details of the problem you're having, but if you have a list of objects (as returned by select_many or children()) called 'my_list', you should be able to use the built-in python sorting methods to get it in the order you want.

I'm setting this to 'won't fix', since, at this point, changing this would complicate matters elsewhere, and it's explicitly documented that you can't rely on the order of returned objects.

Hit me up on IRC if you need any more information.

Cheers,

Changed in xpathselect:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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