/srv/irclogs.ubuntu.com/2015/06/15/#ubuntu-quality.txt

=== vrruiz_ is now known as rvr
=== pgraner-afk is now known as pgraner
=== chihchun is now known as chihchun_afk
=== qwebirc539535 is now known as slickymasterWork
svijballoons: hey, I tried to write my first autopilot test, but I'm struggling… I tried to write a test for this bug: https://bugs.launchpad.net/ubuntu-calculator-app/+bug/1410986 But I don't know how to access the calculationHistory to do a "longpress"18:41
ubot5Launchpad bug 1410986 in Ubuntu Calculator App "[Autopilot] Test delete multiple calculation from history" [Medium,Confirmed]18:41
balloonssvij, howdy18:43
balloonslet's have a look18:43
svij:)18:44
=== pgraner is now known as pgraner-dr
balloonssvij, so I believe step 2 is basically press and hold on the white screen at the top18:52
balloonsit will let you play with the calculations18:52
svijballoons: yes, and I have no idea how to do that18:53
balloonsyou should get an action menu and checkboxes..18:53
balloonsohh, lol, you mean have AP do that :p18:53
svijyeah :D18:53
svijsorry. :D18:53
balloonssvij,are you able to find the object ok?18:53
balloonswe can press and hold using https://developer.ubuntu.com/api/autopilot/python/1.5.0/autopilot.input.Touch/18:54
svijballoons: I'm not sure which object it is (I'm not really familiar with qml)18:55
balloonssvij, awesome, so let's talk about how to figure that out18:56
balloonssvij, have you tried using autopilot vis yet? Because that's how we'll figure out the object18:56
svijhm, nope18:56
svijlet me find the docs…18:57
svijhttps://developer.ubuntu.com/api/autopilot/python/1.5.0/guides-running_ap/#visualise-introspection-tree the images are broken :(18:58
balloonssvij, yikes.. we'll have to fix that!18:59
svij(it's also broken on a couple of other pages of the autopilot pages)18:59
balloonsright, thanks for pointing it out. I'll file a bug on the site nd get it fixed18:59
balloonsanyways, so right. first lanuch the app, then run vis to have a visual look at the introspection tree19:01
balloonsfor calculator I wold do this:19:01
balloonsautopilot launch -i Qt qmlscene app/ubuntu-calculator-app.qml19:01
balloonsautopilot3 vis19:01
svijgot it19:03
svijand selected the calculator app in vis19:03
balloonsexcellent. So now you can see the full tree. It's a little odd to browse at first, but you'll get used to it19:04
balloonslook under the MainView and OrientationHelper to get into the app internals19:05
svijand then?19:05
balloonssee the yellow button next to the spyglass at the top of the app?19:06
svijyes19:06
balloonsif you toggle it, it would highlight the part of the app that the object you select in the tree represents19:06
balloonsthis can sometimes be useful19:06
balloonsso now I would try and figure out / understand what objects are in the top of the calculator19:06
balloonslooking through things, I see a PageStack, other Page definitions, and then finally a header and a scrollable view19:08
svijthe scrollview was hard to find19:10
svijscrollable view*19:10
balloonssvij, yes, sometimes the object tree is just a little confusing. In those cases, let me show you another way to grok the tree19:10
svijand the QQuickLoader seems to be one item of the calculation history19:12
balloonscheck out print_tree() on https://developer.ubuntu.com/api/autopilot/python/1.5.0/autopilot.introspection.ProxyBase/19:12
balloonsso one thing you can do is launch the app under test in python, then do a dump of the tree if you will to a file, using print_tree on the root node19:12
balloonsdoes that make sense?19:12
svijhow do I "launch the app under test in python"?19:13
balloonssvij, that's what is happening in the test cases. So in this case I would add another test case to the test_main.py file, and then have autopilot run it19:15
svijoh right19:15
balloonssvij, something tiny, like def test_dump_tree(self):19:15
balloons        self.app.main_view.print_tree()19:15
svijtrying…19:16
balloonsmake sure you redirect the output to a file when you run :-)19:16
balloonsso it doesn't dump to your console19:17
svijhehe, yes.19:18
svijokay, and now?19:19
balloonswe can review the output. Also, I had a look in the test helpers and noticed there is already a helper for calculationhistory19:20
balloonsdo you see it in __init__.py?19:20
svijyes19:20
balloonsI also see mainview has a helper method already called get_history19:22
svijyes, i see19:22
balloonsif you look inside your dump, you can see this object.. Look for objectName: 'scrollableView'19:23
balloonsanyways, I might suggest that this is exactly what we want to press and hold19:23
balloonswhat do you think?19:23
svijsure19:23
svijbut do I need to press and hold that scrollableView or one item in that scrollableView?19:25
balloonsso let's try. First, use the helper method that already exists to get the object, then use autopilot to press and hold it19:25
balloonswhen you interact with an object, by default autopilot will try and determine it's coordinates, then press in the middle of the object19:26
svijahh19:26
balloonsso that might work just fine for us19:26
svijdo I need the "press_and_hold" method from MainView in __init__.py?19:26
=== jhodapp_ is now known as jhodapp
balloonssvij, no, that's a custom method and by looking at it I can see it's intended to press and hold a button on the keypad19:29
svijoh right19:29
balloonsyea, should be more aptly named / commented19:29
svijso, I'm getting the object with "self.app.main_view.get_history()" right?19:30
balloonsanyways, so just use autopilot methods themselves to click.19:31
balloonssvij, yes19:31
svijso, call ".press()" on that?19:31
svijor tap, with a duration…19:32
balloonssvij, yes but I realized that doesn't help you :-) Have a look at https://developer.ubuntu.com/api/autopilot/python/1.5.0/autopilot.input.Pointer/.. You'll see there's a nice method called click_object19:32
balloonsand move_to_object19:32
balloonsotherwise you'd have to read the object properties yourself, then press at the proper position. Easier to simply use the built-in method AP provides to do this19:33
svijwait, how do I call that exactly?19:35
balloonssvij, so notice you'll need to creating a pointing device, and these methods are for that class. Now, if you look at the CalculatorApp class in __init__.py, you'll see we've done this in the __init__ method19:36
balloonserr sorry.. we declare a property in the class rather . . .19:37
svijum, ok.19:37
balloonsdoes that make sense to you?19:37
balloonsjust know you have a pointing_device ready to go you can use for this stuff under self.app.pointing_device19:38
balloonsso self.app.pointing_device.click_object, self.app.pointing_device.press, etc19:38
svijlet me check…19:39
balloonsyou can learn more about the details of how the app is launched and the objects initialized can come later19:39
svijI've got two lines in my test case right now:19:41
svij        self.app.pointing_device.move_to_object(self.app.main_view.get_history())19:42
svij        self.app.pointing_device.click_object(self)19:42
svijbut that doesn't work19:42
svij"ValueError: Object '<ubuntu_calculator_app.CalculationHistory object at 0x7f2368163c18>' does not have any recognised position attributes19:43
svijoh wait…19:43
balloonssvij, just fyi the self.app.pointing_device.move_to_object isn't needed as click_object will do that for you19:44
balloonssvij, so here's what I wrote:19:44
balloonshistory = self.app.main_view.get_history()19:44
balloonsself.app.pointing_device.click_object(history, 1, 3)19:44
balloonsI got the same error as you, so clearly the object we get from history isn't what is being shown :-)19:45
balloonssince it doesn't have x,y,z coords, it's an internal object.19:45
svijokay19:45
balloonsohh, look at the get_history method again19:46
balloonsit's returning a class19:47
svijyes19:48
svijso…?19:48
balloonsso, we need an object to pass to AP, not a class19:49
svijright19:49
balloonssvij, so notice in __init__, it puts the object in self.app. So we could pass AP the object directly19:50
balloonshistory.app. That runs for me, but doesn't quite do what we want19:51
svijlet me check…19:51
balloonsI hope working through it like this is helping.. I'm going through it slowly with you the same way as I would approach it19:51
svijyeah, sure, it helps. :)19:51
svijand yes, it doesn't really help us.19:53
svij(i mean the code)19:53
balloonsbut you now have the knowledge you need to click the object once we find it19:54
balloonsso at this point I would look deeper into scrollable view. It looks like / my guess is the history we see is laid out in rows19:55
svijit is19:55
svijQQuickLoaders it seems19:56
balloonsso ideally we would enter a calculation, then long press on it's history result I think19:57
balloonsor actually it's asking us to test deleting more than 1 as well19:57
svijyes19:59
svijbut I need to figure out how to access one of those QQuickloaders19:59
balloonssvij, so one thing we can do is use strings to help get us closer to understanding the layout. I would do a print_tree again, but using the calc history object as the root this time.19:59
balloonsThen I would look for a string that is one of the numbers in the history20:00
balloonsdoing that gave me an object under /comubuntucalculator/QQuickView/MainView/OrientationHelper/QQuickItem/QQuickItem/PageStack/PageWrapper/PageWithBottomEdge/ScrollableView/QQuickItem/QQuickColumn/QQuickLoader/Screen/QQuickRectangle/QQuickItem/QQuickColumn/QQuickRow/QQuickText20:01
svijyes20:03
balloonsso at this point, it seems the layout is under Screen. I would go look at the qml and set an objectname on the object I want, if there isn't one20:04
svijok, let me check…20:05
svijballoons: is "screenDelegate" as an objectName okay?20:07
balloonssvij, sure20:07
svijgood :)20:07
svijand now?20:08
svijI think I need to add an "_get_screen" function, which returns the screen?20:09
svijin __init__.py20:09
balloonssvij, sure we could make a helper class with some methods again20:11
balloonsbut I'd get things working first before trying to abstract things20:11
balloonsimho20:11
svijoh, right, sure.20:11
svijlet me try…20:13
balloonsk, I'm looking at / in Screen.qml20:15
balloonsI added objectnames to the results and to the root Screen20:15
* svij thought that this is a simple autopilot test for the beginning :)20:15
balloonssvij, it's turning a little more difficult because we don't have handy access to the objects we need20:16
balloonsbut this is good learning material ;-)20:16
svijyeah, definitely20:16
svijisn't that documented somewhere?20:17
balloonswhat documented?20:17
svijhow to find and access objects without helper functions20:18
balloonswell, that's more or less what vis and print_tree are for. But there's no magical shortcuts besides simply reading the qml20:19
svijoh ok20:19
balloonsthat said, I'm happy to hear of docs that would be helpful. Happy to write them20:19
svijso the result text has objectName20:20
svijbut I added an objectname to the root element20:20
svij(and I'm happy to help to improve the docs ;) )20:21
balloons:-)20:24
balloonsSo I noticed Screen.qml uses ListItemWithActions.qml20:24
svijyes20:24
balloonsso when I added an objectname there, I see it now :-)20:25
balloonsit's a bit odd20:25
svijwait, where do you "see it now"?20:25
balloonsin the dbus tree dumps. I was looking for an objectname under a Screen object20:26
svijdbus tree dump was that print_tree() command, right?20:27
balloonssvij, yes, I've been iterating over running dumps using it..20:28
svijok20:28
balloonsI'm dumping with Screen as the root object20:28
balloonsnote, there appears to be 2 Screen objects also20:29
balloonsso20:29
balloons        screens = self.app.main_view.select_many('Screen')20:29
balloons        for screen in screens:20:29
balloons            screen.print_tree()20:29
svijok20:31
balloonsso, my issue to solve at this point is figure out how to make sure I select a specific object in the list. Doing those dumps shows me there are mutliple result objects for instance.. each result is sharing the same objectname20:31
balloonsnormally we would fix that by adding a dynamic property to the objectname declaration. So for example, objectName: "listitem" + index20:32
svijand in this case (if its not 'normally')?20:33
svijballoons: do you mind, if we continue tomorrow? It's getting late here and I'm really tired now and less concentrated…20:37
balloonssvij, well the qml object is custom it seems. So it's more painful20:37
balloonssvij, no worries. I'll figure out how to assign the objectname sanely so we can get back to the actual test20:37
svijgreat!20:37
balloonsif you encounter something like this, the answer is always ask the developer20:37
balloonswhat on earth is going on in your custom object :-)20:38
svijfirst I need to figure out what are "normal" and what are "custom" objects20:38
svijand how to access them properly ;)20:38
balloonssvij, "normal" is assign the objectname and then see it in the tree and go20:38
balloonslol20:38
svijanyway, thanks so far! I'll ping you tomorrow20:39
balloonsgood night!20:40
svijthanks20:41
balloonsyw20:41

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!