Beispiel #1
0
    def test_CUP_RespectsOriginMode(self):
        """CUP is relative to margins in origin mode."""
        # Set a scroll region.
        esccmd.DECSTBM(6, 11)
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(5, 10)

        # Move to center of region
        esccmd.CUP(Point(7, 9))
        position = GetCursorPosition()
        AssertEQ(position.x(), 7)
        AssertEQ(position.y(), 9)

        # Turn on origin mode.
        esccmd.DECSET(esccmd.DECOM)

        # Move to top-left
        esccmd.CUP(Point(1, 1))

        # Check relative position while still in origin mode.
        position = GetCursorPosition()
        AssertEQ(position.x(), 1)
        AssertEQ(position.y(), 1)

        escio.Write("X")

        # Turn off origin mode. This moves the cursor.
        esccmd.DECRESET(esccmd.DECOM)

        # Turn off scroll regions so checksum can work.
        esccmd.DECSTBM()
        esccmd.DECRESET(esccmd.DECLRMM)

        # Make sure there's an X at 5,6
        AssertScreenCharsInRectEqual(Rect(5, 6, 5, 6), ["X"])
Beispiel #2
0
    def test_VPA_DefaultParams(self):
        """With no params, VPA moves to 1st line."""
        esccmd.VPA(6)

        position = GetCursorPosition()
        AssertEQ(position.y(), 6)

        esccmd.VPA()

        position = GetCursorPosition()
        AssertEQ(position.y(), 1)
Beispiel #3
0
  def test_VPA_DefaultParams(self):
    """With no params, VPA moves to 1st line."""
    esccmd.VPA(6)

    position = GetCursorPosition()
    AssertEQ(position.y(), 6)

    esccmd.VPA()

    position = GetCursorPosition()
    AssertEQ(position.y(), 1)
Beispiel #4
0
    def test_CUP_ColumnOnly(self):
        """Default row is 1."""
        esccmd.CUP(Point(6, 3))

        position = GetCursorPosition()
        AssertEQ(position.x(), 6)
        AssertEQ(position.y(), 3)

        esccmd.CUP(col=2)

        position = GetCursorPosition()
        AssertEQ(position.x(), 2)
        AssertEQ(position.y(), 1)
Beispiel #5
0
  def test_HVP_DefaultParams(self):
    """With no params, HVP moves to 1,1."""
    esccmd.HVP(Point(6, 3))

    position = GetCursorPosition()
    AssertEQ(position.x(), 6)
    AssertEQ(position.y(), 3)

    esccmd.HVP()

    position = GetCursorPosition()
    AssertEQ(position.x(), 1)
    AssertEQ(position.y(), 1)
Beispiel #6
0
  def test_HVP_ColumnOnly(self):
    """Default row is 1."""
    esccmd.HVP(Point(6, 3))

    position = GetCursorPosition()
    AssertEQ(position.x(), 6)
    AssertEQ(position.y(), 3)

    esccmd.HVP(col=2)

    position = GetCursorPosition()
    AssertEQ(position.x(), 2)
    AssertEQ(position.y(), 1)
Beispiel #7
0
  def test_HVP_RowOnly(self):
    """Default column is 1."""
    esccmd.HVP(Point(6, 3))

    position = GetCursorPosition()
    AssertEQ(position.x(), 6)
    AssertEQ(position.y(), 3)

    esccmd.HVP(row=2)

    position = GetCursorPosition()
    AssertEQ(position.x(), 1)
    AssertEQ(position.y(), 2)
Beispiel #8
0
  def test_CUP_RowOnly(self):
    """Default column is 1."""
    esccmd.CUP(Point(6, 3))

    position = GetCursorPosition()
    AssertEQ(position.x(), 6)
    AssertEQ(position.y(), 3)

    esccmd.CUP(row=2)

    position = GetCursorPosition()
    AssertEQ(position.x(), 1)
    AssertEQ(position.y(), 2)
Beispiel #9
0
    def test_CUP_DefaultParams(self):
        """With no params, CUP moves to 1,1."""
        esccmd.CUP(Point(6, 3))

        position = GetCursorPosition()
        AssertEQ(position.x(), 6)
        AssertEQ(position.y(), 3)

        esccmd.CUP()

        position = GetCursorPosition()
        AssertEQ(position.x(), 1)
        AssertEQ(position.y(), 1)
Beispiel #10
0
 def test_HVP_ZeroIsTreatedAsOne(self):
   """Zero args are treated as 1."""
   esccmd.HVP(Point(6, 3))
   esccmd.HVP(col=0, row=0)
   position = GetCursorPosition()
   AssertEQ(position.x(), 1)
   AssertEQ(position.y(), 1)
Beispiel #11
0
 def test_IND_Basic(self):
   """Index moves the cursor down one line."""
   esccmd.CUP(Point(5, 3))
   esccmd.IND()
   position = GetCursorPosition()
   AssertEQ(position.x(), 5)
   AssertEQ(position.y(), 4)
Beispiel #12
0
 def test_CPL_DefaultParam(self):
   """CPL moves the cursor up 1 with no parameter given."""
   esccmd.CUP(Point(5, 3))
   esccmd.CPL()
   position = GetCursorPosition()
   AssertEQ(position.x(), 1)
   AssertEQ(position.y(), 2)
Beispiel #13
0
 def test_NEL_Basic(self):
     """Next Line moves the cursor down one line and to the start of the next line."""
     esccmd.CUP(Point(5, 3))
     esccmd.NEL()
     position = GetCursorPosition()
     AssertEQ(position.x(), 1)
     AssertEQ(position.y(), 4)
Beispiel #14
0
 def test_RI_Basic(self):
   """Reverse index moves the cursor up one line."""
   esccmd.CUP(Point(5, 3))
   esccmd.RI()
   position = GetCursorPosition()
   AssertEQ(position.x(), 5)
   AssertEQ(position.y(), 2)
Beispiel #15
0
 def test_IND_Basic(self):
     """Index moves the cursor down one line."""
     esccmd.CUP(Point(5, 3))
     esccmd.IND()
     position = GetCursorPosition()
     AssertEQ(position.x(), 5)
     AssertEQ(position.y(), 4)
Beispiel #16
0
 def test_VT_Basic(self):
   """VT moves the cursor down one line."""
   esccmd.CUP(Point(5, 3))
   escio.Write(VT)
   position = GetCursorPosition()
   AssertEQ(position.x(), 5)
   AssertEQ(position.y(), 4)
Beispiel #17
0
 def test_CPL_ExplicitParam(self):
   """CPL moves the cursor up by the passed-in number of lines."""
   esccmd.CUP(Point(6, 5))
   esccmd.CPL(2)
   position = GetCursorPosition()
   AssertEQ(position.x(), 1)
   AssertEQ(position.y(), 3)
Beispiel #18
0
 def test_CHA_ExplicitParam(self):
   """CHA moves to specified column of active line."""
   esccmd.CUP(Point(5, 3))
   esccmd.CHA(10)
   position = GetCursorPosition()
   AssertEQ(position.x(), 10)
   AssertEQ(position.y(), 3)
Beispiel #19
0
    def test_VPR_DefaultParams(self):
        """With no params, VPR moves right by 1."""
        esccmd.CUP(Point(1, 6))
        esccmd.VPR()

        position = GetCursorPosition()
        AssertEQ(position.y(), 7)
Beispiel #20
0
 def test_CHA_ZeroParam(self):
   """CHA moves as far left as possible when given a zero parameter."""
   esccmd.CUP(Point(5, 3))
   esccmd.CHA(0)
   position = GetCursorPosition()
   AssertEQ(position.x(), 1)
   AssertEQ(position.y(), 3)
Beispiel #21
0
 def test_CHA_DefaultParam(self):
   """CHA moves to first column of active line by default."""
   esccmd.CUP(Point(5, 3))
   esccmd.CHA()
   position = GetCursorPosition()
   AssertEQ(position.x(), 1)
   AssertEQ(position.y(), 3)
Beispiel #22
0
 def test_NEL_Basic(self):
   """Next Line moves the cursor down one line and to the start of the next line."""
   esccmd.CUP(Point(5, 3))
   esccmd.NEL()
   position = GetCursorPosition()
   AssertEQ(position.x(), 1)
   AssertEQ(position.y(), 4)
Beispiel #23
0
 def test_CUB_DefaultParam(self):
   """CUB moves the cursor left 1 with no parameter given."""
   esccmd.CUP(Point(5, 3))
   esccmd.CUB()
   position = GetCursorPosition()
   AssertEQ(position.x(), 4)
   AssertEQ(position.y(), 3)
Beispiel #24
0
 def test_CUB_DefaultParam(self):
   """CUB moves the cursor left 1 with no parameter given."""
   esccmd.CUP(Point(5, 3))
   esccmd.CUB()
   position = GetCursorPosition()
   AssertEQ(position.x(), 4)
   AssertEQ(position.y(), 3)
Beispiel #25
0
 def test_RI_Basic(self):
     """Reverse index moves the cursor up one line."""
     esccmd.CUP(Point(5, 3))
     esccmd.RI()
     position = GetCursorPosition()
     AssertEQ(position.x(), 5)
     AssertEQ(position.y(), 2)
Beispiel #26
0
 def test_VT_Basic(self):
     """VT moves the cursor down one line."""
     esccmd.CUP(Point(5, 3))
     escio.Write(VT)
     position = GetCursorPosition()
     AssertEQ(position.x(), 5)
     AssertEQ(position.y(), 4)
Beispiel #27
0
  def test_VPR_DefaultParams(self):
    """With no params, VPR moves right by 1."""
    esccmd.CUP(Point(1, 6))
    esccmd.VPR()

    position = GetCursorPosition()
    AssertEQ(position.y(), 7)
Beispiel #28
0
 def test_CUP_ZeroIsTreatedAsOne(self):
     """Zero args are treated as 1."""
     esccmd.CUP(Point(6, 3))
     esccmd.CUP(col=0, row=0)
     position = GetCursorPosition()
     AssertEQ(position.x(), 1)
     AssertEQ(position.y(), 1)
Beispiel #29
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)
Beispiel #30
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())
Beispiel #31
0
  def test_VPA_DoesNotChangeColumn(self):
    """VPA moves the specified line and does not change the column."""
    esccmd.CUP(Point(6, 5))
    esccmd.VPA(2)

    position = GetCursorPosition()
    AssertEQ(position.x(), 6)
    AssertEQ(position.y(), 2)
Beispiel #32
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)
Beispiel #33
0
    def test_VPA_DoesNotChangeColumn(self):
        """VPA moves the specified line and does not change the column."""
        esccmd.CUP(Point(6, 5))
        esccmd.VPA(2)

        position = GetCursorPosition()
        AssertEQ(position.x(), 6)
        AssertEQ(position.y(), 2)
Beispiel #34
0
  def test_HPR_DoesNotChangeRow(self):
    """HPR moves the specified column and does not change the row."""
    esccmd.CUP(Point(5, 6))
    esccmd.HPR(2)

    position = GetCursorPosition()
    AssertEQ(position.x(), 7)
    AssertEQ(position.y(), 6)
Beispiel #35
0
    def test_HPA_DoesNotChangeRow(self):
        """HPA moves the specified column and does not change the row."""
        esccmd.CUP(Point(5, 6))
        esccmd.HPA(2)

        position = GetCursorPosition()
        AssertEQ(position.x(), 2)
        AssertEQ(position.y(), 6)
Beispiel #36
0
    def test_VPR_DoesNotChangeColumn(self):
        """VPR moves the specified row and does not change the column."""
        esccmd.CUP(Point(5, 6))
        esccmd.VPR(2)

        position = GetCursorPosition()
        AssertEQ(position.x(), 5)
        AssertEQ(position.y(), 8)
Beispiel #37
0
    def test_CUP_OutOfBoundsParams(self):
        """With overly large parameters, CUP moves as far as possible down and right."""
        size = GetScreenSize()
        esccmd.CUP(Point(size.width() + 10, size.height() + 10))

        position = GetCursorPosition()
        AssertEQ(position.x(), size.width())
        AssertEQ(position.y(), size.height())
Beispiel #38
0
  def test_VPR_DoesNotChangeColumn(self):
    """VPR moves the specified row and does not change the column."""
    esccmd.CUP(Point(5, 6))
    esccmd.VPR(2)

    position = GetCursorPosition()
    AssertEQ(position.x(), 5)
    AssertEQ(position.y(), 8)
Beispiel #39
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)
Beispiel #40
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)
Beispiel #41
0
 def test_DECSET_SaveRestoreCursor(self):
     """Set saves the cursor position. Reset restores it."""
     esccmd.CUP(Point(2, 3))
     esccmd.DECSET(esccmd.SaveRestoreCursor)
     esccmd.CUP(Point(5, 5))
     esccmd.DECRESET(esccmd.SaveRestoreCursor)
     cursor = GetCursorPosition()
     AssertEQ(cursor.x(), 2)
     AssertEQ(cursor.y(), 3)
Beispiel #42
0
 def test_DECSET_SaveRestoreCursor(self):
   """Set saves the cursor position. Reset restores it."""
   esccmd.CUP(Point(2, 3))
   esccmd.DECSET(esccmd.SaveRestoreCursor)
   esccmd.CUP(Point(5, 5))
   esccmd.DECRESET(esccmd.SaveRestoreCursor)
   cursor = GetCursorPosition()
   AssertEQ(cursor.x(), 2)
   AssertEQ(cursor.y(), 3)
Beispiel #43
0
  def doAltBuftest(self, code, altGetsClearedBeforeToMain, cursorSaved, movesCursorOnEnter=False):
    """|code| is the code to test with, either 47 or 1047."""
    # Scribble in main screen
    escio.Write("abc" + CR + LF + "abc")

    # Switch from main to alt. Cursor should not move. If |cursorSaved| is set,
    # record the position first to verify that it's restored after DECRESET.
    if cursorSaved:
      mainCursorPosition = GetCursorPosition()

    before = GetCursorPosition()
    esccmd.DECSET(code)
    after = GetCursorPosition()
    if not movesCursorOnEnter:
      # 1049 moves the cursor on enter
      AssertEQ(before.x(), after.x())
      AssertEQ(before.y(), after.y())

    # Scribble in alt screen, clearing it first since who knows what might have
    # been there.
    esccmd.ED(2)
    esccmd.CUP(Point(1, 2))
    escio.Write("def" + CR +LF + "def")

    # Make sure abc is gone
    AssertScreenCharsInRectEqual(Rect(1, 1, 3, 3), [empty() * 3, "def", "def"])

    # Switch to main. Cursor should not move.
    before = GetCursorPosition()
    esccmd.DECRESET(code)
    after = GetCursorPosition()
    if cursorSaved:
      AssertEQ(mainCursorPosition.x(), after.x())
      AssertEQ(mainCursorPosition.y(), after.y())
    else:
      AssertEQ(before.x(), after.x())
      AssertEQ(before.y(), after.y())

    # def should be gone, abc should be back.
    AssertScreenCharsInRectEqual(Rect(1, 1, 3, 3), ["abc", "abc", empty() * 3])

    # Switch to alt
    before = GetCursorPosition()
    esccmd.DECSET(code)
    after = GetCursorPosition()
    if not movesCursorOnEnter:
      # 1049 moves the cursor on enter
      AssertEQ(before.x(), after.x())
      AssertEQ(before.y(), after.y())

    if altGetsClearedBeforeToMain:
      AssertScreenCharsInRectEqual(Rect(1, 1, 3, 3), [empty() * 3, empty() * 3, empty() * 3])
    else:
      AssertScreenCharsInRectEqual(Rect(1, 1, 3, 3), [empty() * 3, "def", "def"])
Beispiel #44
0
 def test_CHA_IgnoresScrollRegion(self):
   """CHA ignores scroll regions."""
   # Set a scroll region.
   esccmd.DECSET(esccmd.DECLRMM)
   esccmd.DECSLRM(5, 10)
   esccmd.CUP(Point(5, 3))
   esccmd.CHA(1)
   position = GetCursorPosition()
   AssertEQ(position.x(), 1)
   AssertEQ(position.y(), 3)
Beispiel #45
0
    def test_VPA_IgnoresOriginMode(self):
        """VPA does not respect origin mode."""
        # Set a scroll region.
        esccmd.DECSTBM(6, 11)
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(5, 10)

        # Move to center of region
        esccmd.CUP(Point(7, 9))
        position = GetCursorPosition()
        AssertEQ(position.y(), 9)
        AssertEQ(position.x(), 7)

        # Turn on origin mode.
        esccmd.DECSET(esccmd.DECOM)

        # Move to 2nd line
        esccmd.VPA(2)

        position = GetCursorPosition()
        AssertEQ(position.y(), 2)
Beispiel #46
0
  def test_VPA_IgnoresOriginMode(self):
    """VPA does not respect origin mode."""
    # Set a scroll region.
    esccmd.DECSTBM(6, 11)
    esccmd.DECSET(esccmd.DECLRMM)
    esccmd.DECSLRM(5, 10)

    # Move to center of region
    esccmd.CUP(Point(7, 9))
    position = GetCursorPosition()
    AssertEQ(position.y(), 9)
    AssertEQ(position.x(), 7)

    # Turn on origin mode.
    esccmd.DECSET(esccmd.DECOM)

    # Move to 2nd line
    esccmd.VPA(2)

    position = GetCursorPosition()
    AssertEQ(position.y(), 2)
Beispiel #47
0
    def test_RI_8bit(self):
        esccmd.CUP(Point(5, 3))

        escio.use8BitControls = True
        escio.Write(S8C1T)
        esccmd.RI()
        escio.Write(S7C1T)
        escio.use8BitControls = False

        position = GetCursorPosition()
        AssertEQ(position.x(), 5)
        AssertEQ(position.y(), 2)
Beispiel #48
0
  def test_NEL_8bit(self):
    esccmd.CUP(Point(5, 3))

    escio.use8BitControls = True
    escio.Write(S8C1T)
    esccmd.NEL()
    escio.Write(S7C1T)
    escio.use8BitControls = False

    position = GetCursorPosition()
    AssertEQ(position.x(), 1)
    AssertEQ(position.y(), 4)
Beispiel #49
0
    def doAltBuftest(self, code, altGetsClearedBeforeToMain, cursorSaved):
        """|code| is the code to test with, either 47 or 1047."""
        # Scribble in main screen
        escio.Write("abc" + CR + LF + "abc")

        # Switch from main to alt. Cursor should not move. If |cursorSaved| is set,
        # record the position first to verify that it's restored after DECRESET.
        if cursorSaved:
            mainCursorPosition = GetCursorPosition()

        before = GetCursorPosition()
        esccmd.DECSET(code)
        after = GetCursorPosition()
        AssertEQ(before.x(), after.x())
        AssertEQ(before.y(), after.y())

        # Scribble in alt screen, clearing it first since who knows what might have
        # been there.
        esccmd.ED(2)
        esccmd.CUP(Point(1, 2))
        escio.Write("def" + CR + LF + "def")

        # Make sure abc is gone
        AssertScreenCharsInRectEqual(Rect(1, 1, 3, 3), [NUL * 3, "def", "def"])

        # Switch to main. Cursor should not move.
        before = GetCursorPosition()
        esccmd.DECRESET(code)
        after = GetCursorPosition()
        if cursorSaved:
            AssertEQ(mainCursorPosition.x(), after.x())
            AssertEQ(mainCursorPosition.y(), after.y())
        else:
            AssertEQ(before.x(), after.x())
            AssertEQ(before.y(), after.y())

        # def should be gone, abc should be back.
        AssertScreenCharsInRectEqual(Rect(1, 1, 3, 3), ["abc", "abc", NUL * 3])

        # Switch to alt
        before = GetCursorPosition()
        esccmd.DECSET(code)
        after = GetCursorPosition()
        AssertEQ(before.x(), after.x())
        AssertEQ(before.y(), after.y())

        if altGetsClearedBeforeToMain:
            AssertScreenCharsInRectEqual(Rect(1, 1, 3, 3), [NUL * 3, NUL * 3, NUL * 3])
        else:
            AssertScreenCharsInRectEqual(Rect(1, 1, 3, 3), [NUL * 3, "def", "def"])
Beispiel #50
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)
Beispiel #51
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())
Beispiel #52
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)