diff options
| author | Thomi Richards <thomi.richards@canonical.com> | 2012-03-29 10:18:42 +1300 |
|---|---|---|
| committer | Thomi Richards <thomi.richards@canonical.com> | 2012-03-29 10:18:42 +1300 |
| commit | f1524c80d4217d7274d50ee82ea6f1f636c14a1c (patch) | |
| tree | 3dd58d286b3d7d397c02a0c0b7d0b0593aebbb4e /tests | |
| parent | 692bf054af7d43a76e193dc922dfe236e76f11b0 (diff) | |
Made ValueExceptions more explicit in the ScreenGeometry class.
(bzr r2178.1.1)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/autopilot/autopilot/emulators/X11.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/autopilot/autopilot/emulators/X11.py b/tests/autopilot/autopilot/emulators/X11.py index 1360198d4..cbc5a1605 100644 --- a/tests/autopilot/autopilot/emulators/X11.py +++ b/tests/autopilot/autopilot/emulators/X11.py @@ -333,10 +333,19 @@ class ScreenGeometry: return self._default_screen.get_primary_monitor() def set_primary_monitor(self, monitor): + """Set `monitor` to be the primary monitor. + + `monitor` must be an integer between 0 and the number of configured monitors. + ValueError is raised if an invalid monitor is specified. + + """ + if monitor < 0 or monitor >= self.get_num_monitors(): + raise ValueError('Monitor %d is not in valid range of 0 <= monitor < %d.' % (self.get_num_monitors())) + monitor_name = self._default_screen.get_monitor_plug_name(monitor) - if not monitor_name or len(monitor_name) == 0: - raise ValueError('Invalid monitor found') + if not monitor_name: + raise ValueError('Could not get monitor name from monitor number.') glxinfo_out = subprocess.check_output("glxinfo") for dri in self._blacklisted_drivers: |
