~macslow/unity/backported-remote-add-to-5.0

« back to all changes in this revision

Viewing changes to tests/autopilot/autopilot/emulators/X11.py

Merging with upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
371
371
        Returns a tuple containing (x,y,width,height).
372
372
 
373
373
        """
374
 
        if monitor_number >= self.get_num_monitors():
 
374
        if monitor_number < 0 or monitor_number >= self.get_num_monitors():
375
375
            raise ValueError('Specified monitor number is out of range.')
376
376
        return tuple(self._default_screen.get_monitor_geometry(monitor_number))
377
377
 
 
378
    def is_rect_on_monitor(self, monitor_number, rect):
 
379
        """Returns True if `rect` is _entirely_ on the specified monitor, with no overlap."""
 
380
 
 
381
        if type(rect) is not tuple or len(rect) != 4:
 
382
            raise TypeError("rect must be a tuple of 4 int elements.")
 
383
 
 
384
        (x, y, w, h) = rect
 
385
        (m_x, m_y, m_w, m_h) = self.get_monitor_geometry(monitor_number)
 
386
        return (x >= m_x and x + w <= m_x + m_w and y >= m_y and y + h <= m_y + m_h)
 
387
 
378
388
    def move_mouse_to_monitor(self, monitor_number):
379
389
        """Move the mouse to the center of the specified monitor."""
380
390
        geo = self.get_monitor_geometry(monitor_number)