Hello, On Wed, Jan 22, 2014 at 12:02 PM, Iain Lane <[email protected]> wrote:
> I need to write some tests that operate on ListViews. The contents are > dynamic (some of the models are QAbstractTableModels from C++, even) so > I cannot address the items by objectName. > > How can I get at these? I can select the ListView itself, but I don't > see any way to get a list of elements in the model. I can use the > unreleased emulator for now, if that's necessary. > Copying from my IRC reply... You can do something like: list = main_view.select_single(ubuntuuitoolkit.emulators.QQuickListView) elements = list.select_many(ubuntuuitoolkit.emulators.Base) However, you might find problems with that. For example, if the list element has a list inside, you will get more elements than the ones you should. And you can't do list.select_children(ubuntuuitoolkit.emulators.Base) because there's an extra element between the list and it's elements. Also, qt might be exposing the elements to autopilot in a different order than the one they are being displayed. So if you are using the iterator to click the third element, you would need more checks on the items x and y. One more problem is that qt doesn't create all the elements of the list, so if you are at the top of a long list, autopilot won't know the ones at the end, you iterator needs to scroll the list. For all those problems and some unexpected, what we actually should do is to create an iterator in ubuntuuitoolkit.emulators.QQuickListView that takes care of everything. We are close to be able to do it for vertical lists, just waiting on the autopilot drag improvements I mentioned to you. Quick and dirty solution if you can't wait, go with select_many. But please make a big note saying that it's flaky and we are working on improving it. pura vida. -- ¡paz y baile! http://one.ubuntu.com
-- Mailing list: https://launchpad.net/~ubuntu-phone Post to : [email protected] Unsubscribe : https://launchpad.net/~ubuntu-phone More help : https://help.launchpad.net/ListHelp

