Ejemplo n.º 1
0
  def test_XtermWinops_ResizePixels_ZeroHeight(self):
    """Resize the window to a pixel size, setting one parameter to 0. The
    window should maximize in the direction of the 0 parameter."""
    original_size = GetWindowSizePixels()

    # Set height and maximize width.
    desired_width = 400
    esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_PIXELS,
                            0,
                            desired_width)

    # Make sure the height changed as requested.
    max_error = 20
    actual_size = GetWindowSizePixels()
    AssertTrue(abs(actual_size.width() - desired_width) < max_error)

    # See if the height is about as big as the display (only measurable in
    # characters, not pixels).
    display_size = GetDisplaySize()  # In characters
    screen_size = GetScreenSize()  # In characters
    max_error = 5
    AssertTrue(abs(display_size.height() - screen_size.height()) < max_error)

    # Restore to original size.
    esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_PIXELS,
                            original_size.height(),
                            original_size.width())
Ejemplo n.º 2
0
    def test_XtermWinops_ResizePixels_BothParameters(self):
        """Resize the window to a pixel size, giving both parameters."""
        maximum_size = GetScreenSizePixels()
        original_size = GetWindowSizePixels()
        if escargs.args.expected_terminal == "xterm":
            desired_size = Size(
                self.AverageWidth(maximum_size, original_size),
                self.AverageHeight(maximum_size, original_size))
        else:
            desired_size = Size(400, 200)

        esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_PIXELS, desired_size.height(),
                            desired_size.width())
        self.DelayAfterResize()
        self.CheckActualSizePixels(desired_size)

        esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_PIXELS, original_size.height(),
                            original_size.width())
        self.DelayAfterResize()
Ejemplo n.º 3
0
  def test_XtermWinops_ResizePixels_OmittedWidth(self):
    """Resize the window to a pixel size, omitting one parameter. The size
    should not change in the direction of the omitted parameter."""
    original_size = GetWindowSizePixels()
    desired_size = Size(original_size.width(), 200)

    esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_PIXELS,
                            desired_size.height())
    # See if we're within 20px of the desired size. It won't be exact because
    # most terminals snap to grid.
    actual_size = GetWindowSizePixels()
    error = Size(abs(actual_size.width() - desired_size.width()),
                 abs(actual_size.height() - desired_size.height()))
    max_error = 20
    AssertTrue(error.width() <= max_error)
    AssertTrue(error.height() <= max_error)

    esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_PIXELS,
                            original_size.height(),
                            original_size.width())
Ejemplo n.º 4
0
  def test_XtermWinops_ResizePixels_BothParameters(self):
    """Resize the window to a pixel size, giving both parameters."""
    original_size = GetWindowSizePixels()
    desired_size = Size(400, 200)

    esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_PIXELS,
                            desired_size.height(),
                            desired_size.width())
    # See if we're within 20px of the desired size on each dimension. It won't
    # be exact because most terminals snap to grid.
    actual_size = GetWindowSizePixels()
    error = Size(abs(actual_size.width() - desired_size.width()),
                 abs(actual_size.height() - desired_size.height()))
    max_error = 20
    AssertTrue(error.width() <= max_error)
    AssertTrue(error.height() <= max_error)

    esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_PIXELS,
                            original_size.height(),
                            original_size.width())
Ejemplo n.º 5
0
    def test_XtermWinops_ResizePixels_OmittedHeight(self):
        """Resize the window to a pixel size, omitting one parameter. The size
    should not change in the direction of the omitted parameter."""
        maximum_size = GetScreenSizePixels()
        original_size = GetWindowSizePixels()

        if escargs.args.expected_terminal == "xterm":
            desired_size = Size(maximum_size.width(), original_size.height())
        else:
            desired_size = Size(400, original_size.height())

        esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_PIXELS, None,
                            desired_size.width())
        self.DelayAfterResize()
        self.CheckActualSizePixels(desired_size)

        esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_PIXELS, original_size.height(),
                            original_size.width())
        self.DelayAfterResize()
Ejemplo n.º 6
0
 def CheckActualSizePixels(self, desired_size):
     """After resizing an xterm window using pixel-units, check if it is close
 enough to pass the test."""
     self.CheckAnySize(desired_size, GetWindowSizePixels(),
                       self.GetPixelErrorLimit())
Ejemplo n.º 7
0
    def test_XtermWinops_ResizePixels_ZeroWidth(self):
        """Resize the window to a pixel size, setting one parameter to 0. The
    window should maximize in the direction of the 0 parameter."""
        if escargs.args.expected_terminal == "xterm":
            maximum_size = GetScreenSizePixels()
            original_size = GetWindowSizePixels()

            # Set height and maximize width.
            desired_size = Size(
                maximum_size.width(),
                self.AverageHeight(maximum_size, original_size))
            esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_PIXELS,
                                desired_size.height(), 0)
            self.DelayAfterResize()
            self.CheckActualSizePixels(desired_size)

            # See if the width is about as big as the display (only measurable in
            # characters, not pixels).
            display_size = GetDisplaySize()  # In characters
            screen_size = GetScreenSize()  # In characters
            max_error = 5
            AssertTrue(
                abs(display_size.width() - screen_size.width()) < max_error)

            # Restore to original size.
            esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_PIXELS,
                                original_size.height(), original_size.width())
            self.DelayAfterResize()
        else:
            original_size = GetWindowSizePixels()

            # Set height and maximize width.
            desired_height = 200
            esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_PIXELS, desired_height, 0)

            # Make sure the height changed as requested.
            max_error = 20
            actual_size = GetWindowSizePixels()
            AssertTrue(abs(actual_size.height() - desired_height) < max_error)

            # See if the width is about as big as the display (only measurable in
            # characters, not pixels).
            display_size = GetDisplaySize()  # In characters
            screen_size = GetScreenSize()  # In characters
            max_error = 5
            AssertTrue(
                abs(display_size.width() - screen_size.width()) < max_error)

            # Restore to original size.
            esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_PIXELS,
                                original_size.height(), original_size.width())