Merge lp:~elopio/ubuntu-ui-toolkit/fix1211619-tab_loop into lp:ubuntu-ui-toolkit

Proposed by Leo Arias
Status: Merged
Approved by: Tim Peeters
Approved revision: 694
Merged at revision: 693
Proposed branch: lp:~elopio/ubuntu-ui-toolkit/fix1211619-tab_loop
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 35 lines (+13/-1)
1 file modified
tests/autopilot/ubuntuuitoolkit/emulators.py (+13/-1)
To merge this branch: bzr merge lp:~elopio/ubuntu-ui-toolkit/fix1211619-tab_loop
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Nicholas Skaggs (community) Approve
Ubuntu SDK team Pending
Review via email: mp+180018@code.launchpad.net

Commit message

Added a safeguard to prevent the tabs autopilot emulator to loop for ever.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Thanks elopio ;-)

review: Approve
694. By Leo Arias

Renamed the number of switches var as suggested by Tim.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/ubuntuuitoolkit/emulators.py'
2--- tests/autopilot/ubuntuuitoolkit/emulators.py 2013-08-09 09:56:18 +0000
3+++ tests/autopilot/ubuntuuitoolkit/emulators.py 2013-08-14 14:30:40 +0000
4@@ -20,6 +20,10 @@
5 _NO_TABS_ERROR = 'The MainView has no Tabs.'
6
7
8+class ToolkitEmulatorException(Exception):
9+ """Exception raised when there is an error with the emulator."""
10+
11+
12 def get_pointing_device():
13 """Return the pointing device depending on the platform.
14
15@@ -118,11 +122,19 @@
16
17 """
18 tabs = self.get_tabs()
19- if index >= tabs.get_number_of_tabs():
20+ number_of_tabs = tabs.get_number_of_tabs()
21+ if index >= number_of_tabs:
22 raise IndexError('Tab index out of range.')
23 current_tab = tabs.get_current_tab()
24+ number_of_switches = 0
25 while not tabs.selectedTabIndex == index:
26+ if number_of_switches >= number_of_tabs - 1:
27+ # This prevents a loop. But if this error is ever raised, it's
28+ # likely there's a bug on the emulator or on the QML Tab.
29+ raise ToolkitEmulatorException(
30+ 'The tab with index {0} was not selected.'.format(index))
31 current_tab = self.switch_to_next_tab()
32+ number_of_switches += 1
33 return current_tab
34
35 def switch_to_previous_tab(self):

Subscribers

People subscribed via source and target branches

to status/vote changes: