Пример #1
0
 def test_BS_WrapsInWraparoundMode(self):
   esccmd.DECSET(esccmd.DECAWM)
   esccmd.DECSET(esccmd.ReverseWraparound)
   esccmd.CUP(Point(1, 3))
   escio.Write(esc.BS)
   size = GetScreenSize()
   AssertEQ(GetCursorPosition(), Point(size.width(), 2))
Пример #2
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())
Пример #3
0
 def test_XtermWinops_MaximizeWindow_Vertically(self):
   display_size = GetDisplaySize()
   original_size = GetScreenSize()
   expected_size = Size(width=original_size.width(),
                        height=display_size.height())
   esccmd.XTERM_WINOPS(esccmd.WINOP_MAXIMIZE, esccmd.WINOP_MAXIMIZE_V)
   AssertEQ(GetScreenSize(), expected_size)
Пример #4
0
  def test_FF_MovesDoesNotScrollOutsideLeftRight(self):
    """Cursor moves down but won't scroll when outside left-right region."""
    esccmd.DECSTBM(2, 5)
    esccmd.DECSET(esccmd.DECLRMM)
    esccmd.DECSLRM(2, 5)
    esccmd.CUP(Point(3, 5))
    escio.Write("x")

    # Move past bottom margin but to the right of the left-right region
    esccmd.CUP(Point(6, 5))
    escio.Write(FF)
    # Cursor won't pass bottom or scroll.
    AssertEQ(GetCursorPosition(), Point(6, 5))
    AssertScreenCharsInRectEqual(Rect(3, 5, 3, 5), [ "x" ])

    # Try to move past the bottom of the screen but to the right of the left-right region
    height = GetScreenSize().height()
    esccmd.CUP(Point(6, height))
    escio.Write(FF)
    AssertEQ(GetCursorPosition(), Point(6, height))
    AssertScreenCharsInRectEqual(Rect(3, 5, 3, 5), [ "x" ])

    # Move past bottom margin but to the left of the left-right region
    esccmd.CUP(Point(1, 5))
    escio.Write(FF)
    AssertEQ(GetCursorPosition(), Point(1, 5))
    AssertScreenCharsInRectEqual(Rect(3, 5, 3, 5), [ "x" ])

    # Try to move past the bottom of the screen but to the left of the left-right region
    height = GetScreenSize().height()
    esccmd.CUP(Point(1, height))
    escio.Write(FF)
    AssertEQ(GetCursorPosition(), Point(1, height))
    AssertScreenCharsInRectEqual(Rect(3, 5, 3, 5), [ "x" ])
Пример #5
0
    def test_XtermWinops_Fullscreen(self):
        original_size = GetScreenSize()
        display_size = GetDisplaySize()

        # Enter fullscreen
        esccmd.XTERM_WINOPS(esccmd.WINOP_FULLSCREEN,
                            esccmd.WINOP_FULLSCREEN_ENTER)
        self.DelayAfterResize()

        actual_size = GetScreenSize()
        self.CheckAnySize(display_size, actual_size, Size(3, 3))
        self.CheckForShrinkage(original_size, actual_size)

        # Exit fullscreen
        esccmd.XTERM_WINOPS(esccmd.WINOP_FULLSCREEN,
                            esccmd.WINOP_FULLSCREEN_EXIT)
        self.DelayAfterResize()

        self.CheckForShrinkage(original_size, GetScreenSize())

        # Toggle in
        esccmd.XTERM_WINOPS(esccmd.WINOP_FULLSCREEN,
                            esccmd.WINOP_FULLSCREEN_TOGGLE)
        self.DelayAfterResize()

        self.CheckForShrinkage(original_size, GetScreenSize())

        # Toggle out
        esccmd.XTERM_WINOPS(esccmd.WINOP_FULLSCREEN,
                            esccmd.WINOP_FULLSCREEN_TOGGLE)
        self.DelayAfterResize()

        self.CheckForShrinkage(original_size, GetScreenSize())
Пример #6
0
  def test_XtermWinops_ResizeChars_DefaultWidth(self):
    size = GetScreenSize()
    desired_size = Size(size.width(), 21)

    esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_CHARS,
                            desired_size.height())
    AssertEQ(GetScreenSize(), desired_size)
Пример #7
0
 def test_BS_WrapsInWraparoundMode(self):
     esccmd.DECSET(esccmd.DECAWM)
     esccmd.DECSET(esccmd.ReverseWraparound)
     esccmd.CUP(Point(1, 3))
     escio.Write(esc.BS)
     size = GetScreenSize()
     AssertEQ(GetCursorPosition(), Point(size.width(), 2))
Пример #8
0
 def test_DECSET_ReverseWraparound_Multi(self):
     size = GetScreenSize()
     esccmd.CUP(Point(size.width() - 1, 1))
     escio.Write("abcd")
     esccmd.DECSET(esccmd.ReverseWraparound)
     esccmd.DECSET(esccmd.DECAWM)
     esccmd.CUB(4)
     AssertEQ(GetCursorPosition().x(), size.width() - 1)
Пример #9
0
 def test_DECSET_DECAWM_TabDoesNotWrapAround(self):
   """In auto-wrap mode, tabs to not wrap to the next line."""
   esccmd.DECSET(esccmd.DECAWM)
   size = GetScreenSize()
   for i in xrange(size.width() / 8 + 2):
     escio.Write(TAB)
   AssertEQ(GetCursorPosition().x(), size.width())
   AssertEQ(GetCursorPosition().y(), 1)
Пример #10
0
 def test_DECSET_ReverseWraparound_Multi(self):
   size = GetScreenSize()
   esccmd.CUP(Point(size.width() - 1, 1))
   escio.Write("abcd")
   esccmd.DECSET(esccmd.ReverseWraparound)
   esccmd.DECSET(esccmd.DECAWM)
   esccmd.CUB(4)
   AssertEQ(GetCursorPosition().x(), size.width() - 1)
Пример #11
0
    def test_RIS_ResetDECCOLM(self):
        esccmd.DECSET(esccmd.Allow80To132)
        esccmd.DECSET(esccmd.DECCOLM)
        AssertEQ(GetScreenSize().width(), 132)

        esccmd.RIS()

        AssertEQ(GetScreenSize().width(), 80)
Пример #12
0
  def test_HVP_OutOfBoundsParams(self):
    """With overly large parameters, HVP moves as far as possible down and right."""
    size = GetScreenSize()
    esccmd.HVP(Point(size.width() + 10, size.height() + 10))

    position = GetCursorPosition()
    AssertEQ(position.x(), size.width())
    AssertEQ(position.y(), size.height())
Пример #13
0
 def test_BS_CursorStartsInDoWrapPosition(self):
   """Cursor is right of right edge of screen."""
   size = GetScreenSize()
   esccmd.CUP(Point(size.width() - 1, 1))
   escio.Write("ab")
   escio.Write(esc.BS)
   escio.Write("X")
   AssertScreenCharsInRectEqual(Rect(size.width() - 1, 1, size.width(), 1),
                                [ "Xb" ])
Пример #14
0
 def test_DECSET_DECAWM_TabDoesNotWrapAround(self):
     """In auto-wrap mode, tabs to not wrap to the next line."""
     esccmd.DECSET(esccmd.DECAWM)
     size = GetScreenSize()
     for i in xrange(size.width() / 8 + 2):
         escio.Write(TAB)
     AssertEQ(GetCursorPosition().x(), size.width())
     AssertEQ(GetCursorPosition().y(), 1)
     escio.Write("X")
Пример #15
0
 def test_DECFI_WholeScreenScrolls(self):
     """Starting with the cursor at the right edge of the page (outside the
 margins), verify that DECFI is ignored."""
     size = GetScreenSize()
     esccmd.CUP(Point(size.width(), 1))
     escio.Write("x")
     esccmd.DECFI()
     AssertScreenCharsInRectEqual(
         Rect(size.width() - 1, 1, size.width(), 1), ["x" + empty()])
Пример #16
0
 def test_BS_CursorStartsInDoWrapPosition(self):
     """Cursor is right of right edge of screen."""
     size = GetScreenSize()
     esccmd.CUP(Point(size.width() - 1, 1))
     escio.Write("ab")
     escio.Write(esc.BS)
     escio.Write("X")
     AssertScreenCharsInRectEqual(
         Rect(size.width() - 1, 1, size.width(), 1), ["Xb"])
Пример #17
0
 def test_DECFI_WholeScreenScrolls(self):
   """The spec is confusing and contradictory. It first says "If the cursor is
   at the right margin, then all screen data within the margin moves one column
   to the left" and then says "DECFI is not affected by the margins." I don't
   know what they could mean by the second part."""
   size = GetScreenSize()
   esccmd.CUP(Point(size.width(), 1))
   escio.Write("x")
   esccmd.DECFI()
   AssertScreenCharsInRectEqual(Rect(size.width() - 1, 1, size.width(), 1), [ "x" + NUL ])
Пример #18
0
  def test_XtermWinops_DECSLPP(self):
    """Resize to n lines of height."""
    esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_CHARS,
                            10,
                            90)
    AssertEQ(GetScreenSize(), Size(90, 10))

    esccmd.XTERM_WINOPS(24)
    AssertEQ(GetScreenSize(), Size(90, 24))

    esccmd.XTERM_WINOPS(30)
    AssertEQ(GetScreenSize(), Size(90, 30))
Пример #19
0
 def test_XtermWinops_MaximizeWindow_Vertically(self):
     desired_size = Size(GetScreenSize().width(), GetDisplaySize().height())
     esccmd.XTERM_WINOPS(esccmd.WINOP_MAXIMIZE, esccmd.WINOP_MAXIMIZE_V)
     self.DelayAfterResize()
     actual_size = GetScreenSize()
     esccmd.XTERM_WINOPS(esccmd.WINOP_MAXIMIZE, esccmd.WINOP_MAXIMIZE_EXIT)
     self.DelayAfterResize()
     if escargs.args.expected_terminal == "xterm":
         error_limit = Size(0, 5)
     else:
         error_limit = Size(0, 0)
     self.CheckAnySize(desired_size, actual_size, Size(0, 5))
Пример #20
0
 def test_SM_IRM_DoesNotWrapUnlessCursorAtMargin(self):
   """Insert mode does not cause wrapping."""
   size = GetScreenSize()
   escio.Write("a" * (size.width() - 1))
   escio.Write("b")
   esccmd.CUP(Point(1, 1))
   esccmd.SM(esccmd.IRM)
   AssertScreenCharsInRectEqual(Rect(1, 2, 1, 2), [empty()])
   escio.Write("X")
   AssertScreenCharsInRectEqual(Rect(1, 2, 1, 2), [empty()])
   esccmd.CUP(Point(size.width(), 1))
   escio.Write("YZ")
   AssertScreenCharsInRectEqual(Rect(1, 2, 1, 2), ["Z"])
Пример #21
0
 def test_DECSET_ReverseWraparoundLastCol_BS(self):
     """If the cursor is in the last column and a character was just output and
 reverse-wraparound is on then backspace by 1 has no effect."""
     esccmd.DECSET(esccmd.ReverseWraparound)
     esccmd.DECSET(esccmd.DECAWM)
     size = GetScreenSize()
     esccmd.CUP(Point(size.width() - 1, 1))
     escio.Write("a")
     AssertEQ(GetCursorPosition().x(), size.width())
     escio.Write("b")
     AssertEQ(GetCursorPosition().x(), size.width())
     escio.Write(BS)
     AssertEQ(GetCursorPosition().x(), size.width())
Пример #22
0
  def test_HPR_StopsAtRightEdge(self):
    """HPR won't go past the right edge."""
    # Position on 6th row
    esccmd.CUP(Point(5, 6))

    # Try to move 10 past the right edge
    size = GetScreenSize()
    esccmd.HPR(size.width() + 10)

    # Ensure at the right edge on same row
    position = GetCursorPosition()
    AssertEQ(position.x(), size.width())
    AssertEQ(position.y(), 6)
Пример #23
0
  def test_VPA_StopsAtBottomEdge(self):
    """VPA won't go past the bottom edge."""
    # Position on 5th row
    esccmd.CUP(Point(6, 5))

    # Try to move 10 past the bottom edge
    size = GetScreenSize()
    esccmd.VPA(size.height() + 10)

    # Ensure at the bottom edge on same column
    position = GetCursorPosition()
    AssertEQ(position.x(), 6)
    AssertEQ(position.y(), size.height())
Пример #24
0
 def test_SM_IRM_DoesNotWrapUnlessCursorAtMargin(self):
   """Insert mode does not cause wrapping."""
   size = GetScreenSize()
   escio.Write("a" * (size.width() - 1))
   escio.Write("b")
   esccmd.CUP(Point(1, 1))
   esccmd.SM(esccmd.IRM)
   AssertScreenCharsInRectEqual(Rect(1, 2, 1, 2), [ NUL ])
   escio.Write("X")
   AssertScreenCharsInRectEqual(Rect(1, 2, 1, 2), [ NUL ])
   esccmd.CUP(Point(size.width(), 1))
   escio.Write("YZ")
   AssertScreenCharsInRectEqual(Rect(1, 2, 1, 2), [ "Z" ])
Пример #25
0
  def test_DECSTBM_CursorBelowRegionAtBottomTriesToScroll(self):
    """You cannot perform scrolling outside the margins."""
    esccmd.DECSTBM(2, 3)
    esccmd.CUP(Point(1, 2))
    escio.Write("1" + CR + LF)
    escio.Write("2")
    size = GetScreenSize()
    esccmd.CUP(Point(1, size.height()))
    escio.Write("3" + CR + LF)

    AssertScreenCharsInRectEqual(Rect(1, 2, 1, 3), [ "1", "2" ])
    AssertScreenCharsInRectEqual(Rect(1, size.height(), 1, size.height()), [ "3" ])
    AssertEQ(GetCursorPosition().y(), size.height())
Пример #26
0
    def test_VPR_StopsAtBottomEdge(self):
        """VPR won't go past the bottom edge."""
        # Position on 5th column
        esccmd.CUP(Point(5, 6))

        # Try to move 10 past the bottom edge
        size = GetScreenSize()
        esccmd.VPR(size.height() + 10)

        # Ensure at the bottom edge on same column
        position = GetCursorPosition()
        AssertEQ(position.x(), 5)
        AssertEQ(position.y(), size.height())
Пример #27
0
    def test_HPA_StopsAtRightEdge(self):
        """HPA won't go past the right edge."""
        # Position on 6th row
        esccmd.CUP(Point(5, 6))

        # Try to move 10 past the right edge
        size = GetScreenSize()
        esccmd.HPA(size.width() + 10)

        # Ensure at the right edge on same row
        position = GetCursorPosition()
        AssertEQ(position.x(), size.width())
        AssertEQ(position.y(), 6)
Пример #28
0
    def test_XtermWinops_ResizeChars_DefaultHeight(self):
        original_size = GetScreenSize()
        display_size = GetDisplaySize()
        if escargs.args.expected_terminal == "xterm":
            desired_size = Size(self.AverageWidth(original_size, display_size),
                                original_size.height())
        else:
            desired_size = Size(20, original_size.height())

        esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_CHARS, None,
                            desired_size.width())
        self.DelayAfterResize()

        self.CheckActualSizeChars(desired_size, Size(0, 0))
Пример #29
0
    def test_DECSET_DECAWM(self):
        """Auto-wrap mode."""
        size = GetScreenSize()
        esccmd.CUP(Point(size.width() - 1, 1))
        esccmd.DECSET(esccmd.DECAWM)
        escio.Write("abc")

        AssertScreenCharsInRectEqual(Rect(1, 2, 1, 2), ["c"])

        esccmd.CUP(Point(size.width() - 1, 1))
        esccmd.DECRESET(esccmd.DECAWM)
        escio.Write("ABC")

        AssertScreenCharsInRectEqual(Rect(size.width() - 1, 1, size.width(), 1), ["AC"])
        AssertScreenCharsInRectEqual(Rect(1, 2, 1, 2), ["c"])
Пример #30
0
 def test_DECSCL_Level2DoesntSupportDECRQM(self):
     """VT level 2 does not support DECRQM."""
     escio.Write("Hello world.")
     GetScreenSize()
     esccmd.DECSCL(62, 1)
     GetScreenSize()
     # Make sure DECRQM fails.
     try:
         esccmd.DECRQM(esccmd.IRM, DEC=False)
         escio.ReadCSI('$y')
         # Should not get here.
         AssertTrue(False)
     except InternalError, e:
         # Assert something so the test infrastructure is happy.
         AssertTrue(True)
Пример #31
0
    def test_RIS_ResetDECCOLM(self):
        """Test whether RIS resets DECCOLM.

    The control sequence allowing 80/132 switching is an xterm feature
    not found in DEC terminals.  When doing a full reset, xterm checks
    that, as well as checking if the terminal is currently in 132-column
    mode.  Older versions of xterm would reset the 132-column mode
    before checking if it was enabled, failing this test."""
        esccmd.DECSET(esccmd.Allow80To132)
        esccmd.DECSET(esccmd.DECCOLM)
        AssertEQ(GetScreenSize().width(), 132)

        esccmd.RIS()

        AssertEQ(GetScreenSize().width(), 80)
Пример #32
0
    def test_XtermWinops_ResizeChars_ZeroHeight(self):
        """Resize the window to a character size, setting one param to 0 (max size
    in that direction)."""
        maximum_size = GetDisplaySize()
        original_size = GetScreenSize()
        if escargs.args.expected_terminal == "xterm":
            desired_size = Size(original_size.width(), maximum_size.height())
        else:
            desired_size = Size(20, maximum_size.height())

        esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_CHARS, 0, desired_size.width())
        self.DelayAfterResize()

        limit = self.GetCharErrorLimit()
        limit = Size(0, limit.height())
        self.CheckActualSizeChars(desired_size, limit)
Пример #33
0
    def test_SaveRestoreCursor_Wrap(self):
        """Test the position of the cursor after turning auto-wrap mode on and off.

    According to DEC STD 070 (see description on page 5-139 as well as
    pseudo-code on following pages), resetting auto-wrap mode resets the
    terminal's last-column flag, which tells the terminal if it is in the
    special wrap/last-column state.  Older versions of xterm did not
    save/restore the last-column flag in DECRC, causing the cursor to be the
    second column rather than the first when text is written "past" the
    wrapping point.
    """
        # Turn on wrap and save
        esccmd.DECSET(esccmd.DECAWM)
        self.saveCursor()

        # Turn off and restore
        esccmd.DECRESET(esccmd.DECAWM)
        self.restoreCursor()

        # See if we're wrapping.
        esccmd.CUP(Point(GetScreenSize().width() - 1, 1))
        escio.Write("abcd")
        if escargs.args.expected_terminal == "xterm":
            AssertEQ(GetCursorPosition().y(), 1)
        else:
            AssertEQ(GetCursorPosition().y(), 2)
Пример #34
0
 def test_CHA_OutOfBoundsLarge(self):
   """CHA moves as far as possible when given a too-large parameter."""
   esccmd.CUP(Point(5, 3))
   esccmd.CHA(9999)
   position = GetCursorPosition()
   width = GetScreenSize().width()
   AssertEQ(position.x(), width)
   AssertEQ(position.y(), 3)
Пример #35
0
 def test_CNL_StopsAtBottomLine(self):
     """CNL moves the cursor down, stopping at the last line."""
     esccmd.CUP(Point(6, 3))
     height = GetScreenSize().height()
     esccmd.CNL(height)
     position = GetCursorPosition()
     AssertEQ(position.x(), 1)
     AssertEQ(position.y(), height)
Пример #36
0
 def test_CPL_StopsAtTopLine(self):
   """CPL moves the cursor up, stopping at the last line."""
   esccmd.CUP(Point(6, 3))
   height = GetScreenSize().height()
   esccmd.CPL(height)
   position = GetCursorPosition()
   AssertEQ(position.x(), 1)
   AssertEQ(position.y(), 1)
Пример #37
0
  def test_XtermWinops_ResizeChars_BothParameters(self):
    """Resize the window to a character size, giving both parameters."""
    desired_size = Size(20, 21)

    esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_CHARS,
                            desired_size.height(),
                            desired_size.width())
    AssertEQ(GetScreenSize(), desired_size)
Пример #38
0
    def test_XtermSave_SaveSetState(self):
        # Turn on auto-wrap
        esccmd.DECSET(esccmd.DECAWM)

        # Save the setting
        esccmd.XTERM_SAVE(esccmd.DECAWM)

        # Turn off auto-wrap
        esccmd.DECRESET(esccmd.DECAWM)

        # Restore the setting
        esccmd.XTERM_RESTORE(esccmd.DECAWM)

        # Verify that auto-wrap is on
        size = GetScreenSize()
        esccmd.CUP(Point(size.width() - 1, 1))
        escio.Write("xxx")
        AssertEQ(GetCursorPosition().x(), 2)
Пример #39
0
 def test_DECSET_ResetReverseWraparoundDisablesIt(self):
   """DECRESET of reverse wraparound prevents it from happening."""
   # iTerm2 turns reverse wraparound on by default, while xterm does not.
   esccmd.DECRESET(esccmd.ReverseWraparound)
   esccmd.DECSET(esccmd.DECAWM)
   esccmd.CUP(Point(GetScreenSize().width() - 1, 1))
   escio.Write("abc")
   escio.Write(BS * 5)
   AssertEQ(GetCursorPosition().x(), 1)
Пример #40
0
 def test_DECSET_ReverseWraparound_RequiresDECAWM(self):
   """Reverse wraparound only works if DECAWM is set."""
   # iTerm2 turns reverse wraparound on by default, while xterm does not.
   esccmd.CUP(Point(GetScreenSize().width() - 1, 1))
   escio.Write("abc")
   esccmd.DECSET(esccmd.ReverseWraparound)
   esccmd.DECRESET(esccmd.DECAWM)
   escio.Write(BS * 5)
   AssertEQ(GetCursorPosition().x(), 1)
Пример #41
0
  def test_XtermSave_SaveSetState(self):
    # Turn on auto-wrap
    esccmd.DECSET(esccmd.DECAWM)

    # Save the setting
    esccmd.XTERM_SAVE(esccmd.DECAWM)

    # Turn off auto-wrap
    esccmd.DECRESET(esccmd.DECAWM)

    # Restore the setting
    esccmd.XTERM_RESTORE(esccmd.DECAWM)

    # Verify that auto-wrap is on
    size = GetScreenSize()
    esccmd.CUP(Point(size.width() - 1, 1))
    escio.Write("xxx")
    AssertEQ(GetCursorPosition().x(), 2)
Пример #42
0
 def test_DECSET_ReverseWraparound_BS(self):
   """xterm supports DECSET 45 to toggle 'reverse wraparound'. Both DECAWM and
   45 must be set."""
   # iTerm2 turns reverse wraparound on by default, while xterm does not.
   esccmd.DECSET(esccmd.ReverseWraparound)
   esccmd.DECSET(esccmd.DECAWM)
   esccmd.CUP(Point(1, 2))
   escio.Write(BS)
   AssertEQ(GetCursorPosition().x(), GetScreenSize().width())
Пример #43
0
  def test_DECSTBM_MaxSizeOfRegionIsPageSize(self):
    """The maximum size of the scrolling region is the page size."""
    # Write "x" at line 2
    esccmd.CUP(Point(1, 2))
    escio.Write("x")

    # Set the scroll bottom to below the screen.
    size = GetScreenSize()
    esccmd.DECSTBM(1, GetScreenSize().height() + 10)

    # Move the cursor to the last line and write a newline.
    esccmd.CUP(Point(1, size.height()))
    escio.Write(CR + LF)

    # Verify that line 2 scrolled up to line 1.
    AssertScreenCharsInRectEqual(Rect(1, 1, 1, 2), [ "x", NUL ])

    # Verify the cursor is at the last line on the page.
    AssertEQ(GetCursorPosition().y(), size.height())
Пример #44
0
  def test_DECSTBM_BottomOfZeroIsBottomOfScreen(self):
    """A zero value for the bottom arg gives the bottom of the screen."""
    # Write "x" at line 3
    esccmd.CUP(Point(1, 3))
    escio.Write("x")

    # Set the scroll bottom to below the screen.
    size = GetScreenSize()
    esccmd.DECSTBM(2, 0)

    # Move the cursor to the last line and write a newline.
    esccmd.CUP(Point(1, size.height()))
    escio.Write(CR + LF)

    # Verify that line 3 scrolled up to line 2.
    AssertScreenCharsInRectEqual(Rect(1, 2, 1, 3), [ "x", NUL ])

    # Verify the cursor is at the last line on the page.
    AssertEQ(GetCursorPosition().y(), size.height())
Пример #45
0
  def fillRectangle_defaultArgs(self):
    """Write a value at each corner, run fill with no args, and verify the
    corners have all been replaced with self.character."""
    size = GetScreenSize()
    points = [ Point(1, 1),
               Point(size.width(), 1),
               Point(size.width(), size.height()),
               Point(1, size.height()) ]
    n = 1
    for point in points:
      esccmd.CUP(point)
      escio.Write(str(n))
      n += 1

    self.fill()

    for point in points:
      AssertScreenCharsInRectEqual(
          Rect(point.x(), point.y(), point.x(), point.y()),
          [ self.characters(point, 1) ])
Пример #46
0
    def test_DECSET_DECAWM_CursorAtRightMargin(self):
        """If you start at column 1 and write N+1 characters (where N is the width of
    the window) the cursor's position should go: 1, 2, ..., N, N, 2."""
        esccmd.DECSET(esccmd.DECAWM)
        size = GetScreenSize()

        # 1, 2, ... N - 2
        AssertEQ(GetCursorPosition().x(), 1)
        for i in xrange(size.width() - 2):
            escio.Write("x")
        AssertEQ(GetCursorPosition().x(), size.width() - 1)

        # Write the N-1th character, cursor enters the right margin.
        escio.Write("x")
        AssertEQ(GetCursorPosition().x(), size.width())

        # Nth: cursor still at right margin!
        escio.Write("x")
        AssertEQ(GetCursorPosition().x(), size.width())

        # N+1th: cursor wraps around to second position.
        escio.Write("x")
        AssertEQ(GetCursorPosition().x(), 2)
Пример #47
0
  def test_DECCRA_destinationPartiallyOffscreen(self):
    self.prepare()
    size = GetScreenSize()

    esccmd.DECCRA(source_top=2,
                      source_left=2,
                      source_bottom=4,
                      source_right=4,
                      source_page=1,
                      dest_top=size.height() - 1,
                      dest_left=size.width() - 1,
                      dest_page=1)
    AssertScreenCharsInRectEqual(Rect(size.width() - 1,
                                      size.height() - 1,
                                      size.width(),
                                      size.height()),
                                 [ "jk",
                                   "rj" ])
Пример #48
0
  def test_DECSTBM_TopBelowBottom(self):
    """The value of the top margin (Pt) must be less than the bottom margin (Pb)."""
    size = GetScreenSize()
    esccmd.DECSTBM(3, 3)
    for i in xrange(size.height()):
      escio.Write("%04d" % i)
      y = i + 1
      if y != size.height():
        escio.Write(CR + LF)
    for i in xrange(size.height()):
      y = i + 1
      AssertScreenCharsInRectEqual(Rect(1, y, 4, y), [ "%04d" % i ])
    esccmd.CUP(Point(1, size.height()))
    escio.Write(LF)
    for i in xrange(size.height() - 1):
      y = i + 1
      AssertScreenCharsInRectEqual(Rect(1, y, 4, y), [ "%04d" % (i + 1) ])

    y = size.height()
    AssertScreenCharsInRectEqual(Rect(1, y, 4, y), [ NUL * 4 ])
Пример #49
0
 def test_DECALN_FillsScreen(self):
   """Makes sure DECALN fills the screen with the letter E (could be anything,
   but xterm uses E). Testing the whole screen would be slow so we just check
   the corners and center."""
   esccmd.DECALN()
   size = GetScreenSize()
   AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), [ "E" ])
   AssertScreenCharsInRectEqual(Rect(size.width(), 1, size.width(), 1), [ "E" ])
   AssertScreenCharsInRectEqual(Rect(1, size.height(), 1, size.height()), [ "E" ])
   AssertScreenCharsInRectEqual(Rect(size.width(), size.height(), size.width(), size.height()),
                                [ "E" ])
   AssertScreenCharsInRectEqual(Rect(size.width() / 2,
                                    size.height() / 2,
                                    size.width() / 2,
                                    size.height() / 2),
                                [ "E" ])
Пример #50
0
  def test_DECCRA_overlyLargeSourceClippedToScreenSize(self):
    size = GetScreenSize()

    # Put ab, cX in the bottom right
    esccmd.CUP(Point(size.width() - 1, size.height() - 1))
    escio.Write("ab")
    esccmd.CUP(Point(size.width() - 1, size.height()))
    escio.Write("cX")

    # Copy a 2x2 block starting at the X to the a
    esccmd.DECCRA(source_top=size.height(),
                      source_left=size.width(),
                      source_bottom=size.height() + 1,
                      source_right=size.width() + 1,
                      source_page=1,
                      dest_top=size.height() - 1,
                      dest_left=size.width() - 1,
                      dest_page=1)
    AssertScreenCharsInRectEqual(Rect(size.width() - 1,
                                      size.height() - 1,
                                      size.width(),
                                      size.height()),
                                 [ "Xb", "cX" ])
Пример #51
0
  def fillRectangle_overlyLargeSourceClippedToScreenSize(self):
    size = GetScreenSize()

    # Put ab, cX in the bottom right
    esccmd.CUP(Point(size.width() - 1, size.height() - 1))
    escio.Write("ab")
    esccmd.CUP(Point(size.width() - 1, size.height()))
    escio.Write("cd")

    # Fill a 2x2 block starting at the d.
    self.fill(top=size.height(),
              left=size.width(),
              bottom=size.height() + 10,
              right=size.width() + 10)
    AssertScreenCharsInRectEqual(Rect(size.width() - 1,
                                      size.height() - 1,
                                      size.width(),
                                      size.height()),
                                 [ "ab",
                                   "c" + self.characters(Point(size.width(), size.height()), 1) ])
Пример #52
0
 def fillLineAndWriteTab(self):
     escio.Write(CR + LF)
     size = GetScreenSize()
     for i in xrange(size.width()):
         escio.Write("x")
     escio.Write(TAB)
Пример #53
0
 def test_DECFI_NoWrapOnRightEdge(self):
   size = GetScreenSize()
   esccmd.CUP(Point(size.width(), 2))
   esccmd.DECFI()
   AssertEQ(GetCursorPosition(), Point(size.width(), 2))
Пример #54
0
  def test_XtermWinops_Fullscreen(self):
    original_size = GetScreenSize()
    display_size = GetDisplaySize()

    # Enter fullscreen
    esccmd.XTERM_WINOPS(esccmd.WINOP_FULLSCREEN,
                            esccmd.WINOP_FULLSCREEN_ENTER)
    time.sleep(1)
    actual_size = GetScreenSize()
    AssertTrue(actual_size.width() >= display_size.width())
    AssertTrue(actual_size.height() >= display_size.height())

    AssertTrue(actual_size.width() >= original_size.width())
    AssertTrue(actual_size.height() >= original_size.height())

    # Exit fullscreen
    esccmd.XTERM_WINOPS(esccmd.WINOP_FULLSCREEN,
                            esccmd.WINOP_FULLSCREEN_EXIT)
    AssertEQ(GetScreenSize(), original_size)

    # Toggle in
    esccmd.XTERM_WINOPS(esccmd.WINOP_FULLSCREEN,
                            esccmd.WINOP_FULLSCREEN_TOGGLE)
    AssertTrue(actual_size.width() >= display_size.width())
    AssertTrue(actual_size.height() >= display_size.height())

    AssertTrue(actual_size.width() >= original_size.width())
    AssertTrue(actual_size.height() >= original_size.height())

    # Toggle out
    esccmd.XTERM_WINOPS(esccmd.WINOP_FULLSCREEN,
                            esccmd.WINOP_FULLSCREEN_TOGGLE)
    AssertEQ(GetScreenSize(), original_size)