Merge lp:~dpniel/ubiquity/fix-1479064 into lp:ubiquity

Proposed by Dan Chapman 
Status: Merged
Approved by: Mathieu Trudel-Lapierre
Approved revision: 6314
Merged at revision: 6323
Proposed branch: lp:~dpniel/ubiquity/fix-1479064
Merge into: lp:ubiquity
Diff against target: 66 lines (+37/-7)
1 file modified
autopilot/ubiquity_autopilot_tests/emulators/gtkcontrols.py (+37/-7)
To merge this branch: bzr merge lp:~dpniel/ubiquity/fix-1479064
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre Approve
Max Brustkern (community) Approve
Review via email: mp+270226@code.launchpad.net

Description of the change

[Autopilot tests] Fix handling of globalRect mismatches

Previously the test code would look up a GtkTreeView's GtkTreeViewAccessible
counterpart based on sharing the same globalRect co-ordinates and being
visible.

For some reason the coordinates seem to be slightly out each time, meaning
I had to extend the code to lookup all GtkTreeViewAccessible objects across
all tree's and find any that were within range of the GtkTreeView co-ords.
Although all steps (GtkContainers) of the installer are visible at all times
the actual step content is only visible when at that current step. So we can
be pretty sure there will only be one matching gtktreeviewaccessible object
within the given range on that particular step.

This patch seems to work pretty well for now.I did previously try
something a bit more complicated with raw xpath selecting but it
didn't seem to work out so well and was flaky at times.

This patch only fixes the mis-matched global rects and a fix is still needed
for the new "Confirm overwrite disk" dialog

Testing:

It's best to run the test_custom_install test to check this patch works for more than just the language selection treeview as it's also used in the manual partition step.

The runner can be setup to run this branch by creating a config file similar to the testrunner.cfg located in ubiquity-autopilot-runner/config and then run

  $ ./run-ubiquity-test -T path/to/testrunner.cfg --test ubiquity_autopilot_tests.tests.test_custom_install --sdl /path/to/wily-desktop-amd64.iso

The test will get blocked at the overwrite dialog step but you can either just close the runner or manually click the continue button to continue with the install as the test will carry on running.

To post a comment you must log in.
lp:~dpniel/ubiquity/fix-1479064 updated
6314. By Dan Chapman 

Fix pep8 warnings

Revision history for this message
Max Brustkern (nuclearbob) wrote :

Now that I've actually managed to test this correctly, it appears to work. I'll continue testing the other branches as well, but this one looks good to me.

review: Approve
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/ubiquity_autopilot_tests/emulators/gtkcontrols.py'
2--- autopilot/ubiquity_autopilot_tests/emulators/gtkcontrols.py 2014-06-30 13:09:16 +0000
3+++ autopilot/ubiquity_autopilot_tests/emulators/gtkcontrols.py 2015-09-05 07:53:16 +0000
4@@ -332,18 +332,14 @@
5 Gets the GtkTreeViews corresponding GtkTreeViewAccessible object
6 """
7 logger.debug('Getting corresponding GtkTreeViewAccessible object')
8- # lets get a root instance
9- root = self.get_root_instance()
10- assert root is not None
11 # As the treeview item is in the GAILWindow tree and not our current
12 # tree We want to select the treeviewaccessible with the same
13 # globalRect as us
14- logger.debug('Selecting GtkTreeViewAccessible with same globalRect')
15- treeviews = root.select_many('GtkTreeViewAccessible',
16- globalRect=self.globalRect)
17+ logger.debug('Selecting GtkTreeViewAccessible with same globalRect,\
18+ or at least within close range')
19 # if the treeviews are nested they could potentially have the
20 # same globalRect so lets pick out the one thats visible
21- for treeview in treeviews:
22+ for treeview in self._get_all_atktreeviews_within_range():
23 if treeview.visible:
24 logger.debug('GtkTreeViewAccessible object found, '
25 'returning object.')
26@@ -352,6 +348,40 @@
27 "No treeview visible with globalRect {0}".format(self.globalRect)
28 )
29
30+ # So this is a workaround for the ATK treeviews globalrect
31+ # being slightly different compared to it's GtkTreeView counterpart.
32+ def _get_all_atktreeviews_within_range(self, ):
33+ # lets get a root instance
34+ root = self.get_root_instance()
35+ assert root is not None
36+ treeviews = []
37+ # This is going to be slow! but what more can we do? we can't put
38+ # an in range arg on the select_many call :-(
39+ for tree in root.select_many('GtkTreeViewAccessible'):
40+ # There will be some tree's that don't have a globalRect property
41+ # no idea why but we can just ignore them as we can be sure
42+ # this isn't the one we want.
43+ if "globalRect" not in tree.get_properties():
44+ logger.debug("TreeView doesn't have globalRect property")
45+ continue
46+ # assume every treeview is in range unless we find out otherwise
47+ in_range = True
48+ i = 0
49+ # Get a list of all ATK treeviews with globalRect within a
50+ # 5px range of this GtkTreeView
51+ # FIXME: is 5px too much?? It's unlikely more than one tree will
52+ # be within this range anyway, as they would be overlaying each
53+ # other.
54+ # Even if they are only one will be visible (we hope!)
55+ for r in self.globalRect:
56+ if r not in range(tree.globalRect[i] - 5,
57+ tree.globalRect[i] + 5):
58+ in_range = False
59+ i += 1
60+ if in_range:
61+ treeviews.append(tree)
62+ return treeviews
63+
64
65 class GtkComboBox(AutopilotGtkEmulatorBase):
66 """ Emulator class for a GtComboBox instance"""

Subscribers

People subscribed via source and target branches

to status/vote changes: