コード例 #1
0
ファイル: decdc.py プロジェクト: migueldeicaza/esctest
    def test_DECDC_CursorWithinTopBottom(self):
        """DECDC should only affect rows inside region."""
        esccmd.DECSTBM()
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(1, 20)
        # Write four lines. The middle two will be in the scroll region.
        esccmd.CUP(Point(1, 1))
        escio.Write("abcdefg" + CR + LF + "ABCDEFG" + CR + LF + "zyxwvut" +
                    CR + LF + "ZYXWVUT")
        # Define a scroll region. Place the cursor in it. Insert a column.
        esccmd.DECSTBM(2, 3)
        esccmd.CUP(Point(2, 2))
        esccmd.DECDC(2)

        # Remove scroll region and see if it worked.
        esccmd.DECSTBM()
        esccmd.DECRESET(esccmd.DECLRMM)
        AssertScreenCharsInRectEqual(Rect(1, 1, 7, 4), [
            "abcdefg", "ADEFG" + empty() * 2, "zwvut" + empty() * 2, "ZYXWVUT"
        ])
コード例 #2
0
    def test_DL_DefaultParam(self):
        """DL with no parameter should delete a single line."""
        # Set up the screen with 0001, 0002, ..., height
        self.prepare()

        # Delete the second line, moving subsequent lines up.
        esccmd.DL()

        # Build an array of 0001, 0003, 0004, ..., height
        height = GetScreenSize().height()
        y = 1
        expected_lines = []
        for i in xrange(height):
            if y != 2:
                expected_lines.append("%04d" % y)
            y += 1

        # The last line should be blank
        expected_lines.append(empty() * 4)
        AssertScreenCharsInRectEqual(Rect(1, 1, 4, height), expected_lines)
コード例 #3
0
  def test_FF_StopsAtBottomLineWhenBegunBelowScrollRegion(self):
    """When the cursor starts below the scroll region, index moves it down to the
    bottom of the screen but won't scroll."""
    # Set a scroll region. This must be done first because DECSTBM moves the cursor to the origin.
    esccmd.DECSTBM(4, 5)

    # Position the cursor below the scroll region
    esccmd.CUP(Point(1, 6))
    escio.Write("x")

    # Move it down by a lot
    height = GetScreenSize().height()
    for i in xrange(height):
      escio.Write(FF)

    # Ensure it stopped at the bottom of the screen
    AssertEQ(GetCursorPosition().y(), height)

    # Ensure no scroll
    AssertScreenCharsInRectEqual(Rect(1, 6, 1, 6), ["x"])
コード例 #4
0
ファイル: ich.py プロジェクト: unixfreaxjp/Therm
    def test_ICH_ScrollOffRightMarginInScrollRegion(self):
        """Test ICH when cursor is within the scroll region."""
        esccmd.CUP(Point(1, 1))
        s = "abcdefg"
        escio.Write(s)

        # Set margin: from columns 2 to 5
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(2, 5)

        # Position cursor inside margins
        esccmd.CUP(Point(3, 1))

        # Insert blank
        esccmd.ICH()

        # Ensure the 'e' gets dropped.
        esccmd.DECRESET(esccmd.DECLRMM)
        AssertScreenCharsInRectEqual(Rect(1, 1, len(s), 1),
                                     ["ab" + blank() + "cdfg"])
コード例 #5
0
ファイル: fill_rectangle.py プロジェクト: unixfreaxjp/Therm
    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)
            ])
コード例 #6
0
    def test_RI_StopsAtTopLineWhenBegunAboveScrollRegion(self):
        """When the cursor starts above the scroll region, reverse index moves it
    up to the top of the screen but won't scroll."""
        # Set a scroll region. This must be done first because DECSTBM moves the
        # cursor to the origin.
        esccmd.DECSTBM(4, 5)

        # Position the cursor above the scroll region
        esccmd.CUP(Point(1, 3))
        escio.Write("x")

        # Move it up by a lot
        height = GetScreenSize().height()
        for _ in xrange(height):
            esccmd.RI()

        # Ensure it stopped at the top of the screen
        AssertEQ(GetCursorPosition().y(), 1)

        # Ensure no scroll
        AssertScreenCharsInRectEqual(Rect(1, 3, 1, 3), ["x"])
コード例 #7
0
ファイル: decdc.py プロジェクト: unixfreaxjp/Therm
    def test_DECDC_DeleteAllWithLeftRightMargins(self):
        """Test DECDC when cursor is within the scroll region."""
        esccmd.CUP(Point(1, 1))
        s = "abcdefg"
        escio.Write(s)
        esccmd.CUP(Point(1, 2))
        escio.Write(s.upper())

        # Set margin: from columns 2 to 5
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(2, 5)

        # Position cursor inside margins
        esccmd.CUP(Point(3, 1))

        # Insert blank
        esccmd.DECDC(99)

        esccmd.DECRESET(esccmd.DECLRMM)
        AssertScreenCharsInRectEqual(Rect(
            1, 1, 7, 2), ["ab" + NUL * 3 + "fg", "AB" + NUL * 3 + "FG"])
コード例 #8
0
ファイル: deccra.py プロジェクト: migueldeicaza/esctest
    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"])
コード例 #9
0
    def test_DECSCL_Level4_SupportsDECSLRMDoesntSupportDECNCSM(self):
        # Set level 4 conformance
        esccmd.DECSCL(64, 1)

        # Enable DECCOLM.
        esccmd.DECSET(esccmd.Allow80To132)

        # Set DECNCSM, Set column mode. Screen should be cleared anyway.
        esccmd.DECRESET(esccmd.DECCOLM)
        esccmd.DECSET(esccmd.DECNCSM)
        esccmd.CUP(Point(1, 1))
        escio.Write("1")
        esccmd.DECSET(esccmd.DECCOLM)
        AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), [empty()])

        # Make sure DECSLRM succeeds.
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(5, 6)
        esccmd.CUP(Point(5, 1))
        escio.Write("abc")
        AssertEQ(GetCursorPosition().x(), 6)
コード例 #10
0
    def test_DL_ExplicitParam(self):
        """DL should delete the given number of lines."""
        # Set up the screen with 0001, 0002, ..., height
        self.prepare()

        # Delete two lines starting at the second line, moving subsequent lines up.
        esccmd.DL(2)

        # Build an array of 0001, 0004, ..., height
        height = GetScreenSize().height()
        y = 1
        expected_lines = []
        for i in xrange(height):
            if y < 2 or y > 3:
                expected_lines.append("%04d" % y)
            y += 1

        # The last two lines should be blank
        expected_lines.append(NUL * 4)
        expected_lines.append(NUL * 4)

        AssertScreenCharsInRectEqual(Rect(1, 1, 4, height), expected_lines)
コード例 #11
0
ファイル: fill_rectangle.py プロジェクト: unixfreaxjp/Therm
    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)])
コード例 #12
0
ファイル: fill_rectangle.py プロジェクト: unixfreaxjp/Therm
    def fillRectangle_ignoresMargins(self):
        self.prepare()

        # Set margins
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(3, 6)
        esccmd.DECSTBM(3, 6)

        # Fill!
        self.fill(top=5, left=5, bottom=7, right=7)

        # Remove margins
        esccmd.DECRESET(esccmd.DECLRMM)
        esccmd.DECSTBM()

        # Did it ignore the margins?
        AssertScreenCharsInRectEqual(Rect(1, 1, 8, 8), [
            "abcdefgh", "ijklmnop", "qrstuvwx", "yz012345",
            "ABCD" + self.characters(Point(5, 5), 3) + "H",
            "IJKL" + self.characters(Point(5, 6), 3) + "P",
            "QRST" + self.characters(Point(5, 7), 3) + "X", "YZ6789!@"
        ])
コード例 #13
0
ファイル: cha.py プロジェクト: unixfreaxjp/Therm
  def test_CHA_RespectsOriginMode(self):
    """CHA is relative to left margin 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 but not the left, so CHA has something to do.
    esccmd.CUP(Point(2, 1))

    # Move to leftmost column in the scroll region.
    esccmd.CHA(1)

    # Check relative position while still in origin mode.
    position = GetCursorPosition()
    AssertEQ(position.x(), 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" ])
コード例 #14
0
    def test_DECSTR_DECOM(self):
        # Define a scroll region
        esccmd.DECSTBM(3, 4)

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

        # Perform soft reset
        esccmd.DECSTR()

        # Define scroll region again
        esccmd.DECSTBM(3, 4)

        # Move to 1,1 (or 3,4 if origin mode is still on) and write an X
        esccmd.CUP(Point(1, 1))
        escio.Write("X")

        # Turn off origin mode
        esccmd.DECRESET(esccmd.DECOM)

        # Make sure the X was at 1, 1, implying origin mode was off.
        esccmd.DECSTBM()
        AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), ["X"])
コード例 #15
0
ファイル: decdc.py プロジェクト: migueldeicaza/esctest
    def test_DECDC_IsNoOpWhenCursorBeginsOutsideScrollRegion(self):
        """Ensure DECDC does nothing when the cursor starts out outside the scroll
    region.

    DEC STD 070 is explicit on this, saying:
    DECDC is ignored if the active position is outside the Scroll Area.
    """
        esccmd.CUP(Point(1, 1))
        escio.Write("abcdefg" + CR + LF + "ABCDEFG")

        # Set margin: from columns 2 to 5
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(2, 5)

        # Position cursor outside margins
        esccmd.CUP(Point(1, 1))

        # Insert blanks
        esccmd.DECDC(10)

        # Ensure nothing happened.
        esccmd.DECRESET(esccmd.DECLRMM)
        AssertScreenCharsInRectEqual(Rect(1, 1, 7, 2), ["abcdefg", "ABCDEFG"])
コード例 #16
0
  def test_HVP_RespectsOriginMode(self):
    """HVP 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.HVP(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.HVP(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" ])
コード例 #17
0
ファイル: decsel.py プロジェクト: migueldeicaza/esctest
 def test_DECSEL_1(self):
     """Should erase to left of cursor."""
     self.prepare()
     esccmd.DECSEL(1)
     AssertScreenCharsInRectEqual(Rect(1, 1, 10, 1),
                                  [5 * blank() + "fghij"])
コード例 #18
0
ファイル: decsel.py プロジェクト: migueldeicaza/esctest
 def test_DECSEL_0(self):
     """Should erase to right of cursor."""
     self.prepare()
     esccmd.DECSEL(0)
     AssertScreenCharsInRectEqual(Rect(1, 1, 10, 1), ["abcd" + 6 * empty()])
コード例 #19
0
ファイル: ris.py プロジェクト: ThomasDickey/esctest
    def test_RIS_ClearsScreen(self):
        escio.Write("x")

        esccmd.RIS()

        AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), [empty()])
コード例 #20
0
 def test_DCH_ExplicitParam(self):
   """DCH deletes the specified number of parameters."""
   escio.Write("abcd")
   esccmd.CUP(Point(2, 1))
   esccmd.DCH(2)
   AssertScreenCharsInRectEqual(Rect(1, 1, 4, 1), [ "ad" + NUL * 2 ]);
コード例 #21
0
 def test_SD_DefaultParam(self):
     """SD with no parameter should scroll the screen contents down one line."""
     self.prepare()
     esccmd.SD()
     expected_lines = [NUL * 5, "abcde", "fghij", "klmno", "pqrst"]
     AssertScreenCharsInRectEqual(Rect(1, 1, 5, 5), expected_lines)
コード例 #22
0
ファイル: il.py プロジェクト: unixfreaxjp/Therm
 def test_IL_ExplicitParam(self):
     """Should insert two lines below the cursor."""
     self.prepare_wide()
     esccmd.IL(2)
     AssertScreenCharsInRectEqual(Rect(
         1, 1, 5, 5), ["abcde", "fghij", NUL * 5, NUL * 5, "klmno"])
コード例 #23
0
 def test_DCH_DefaultParam(self):
   """DCH with no parameter should delete one character at the cursor."""
   escio.Write("abcd")
   esccmd.CUP(Point(2, 1))
   esccmd.DCH()
   AssertScreenCharsInRectEqual(Rect(1, 1, 4, 1), [ "acd" + NUL ]);
コード例 #24
0
ファイル: il.py プロジェクト: unixfreaxjp/Therm
 def test_IL_DefaultParam(self):
     """Should insert a single line below the cursor."""
     self.prepare_wide()
     esccmd.IL()
     AssertScreenCharsInRectEqual(Rect(1, 1, 5, 4),
                                  ["abcde", "fghij", NUL * 5, "klmno"])
コード例 #25
0
ファイル: rep.py プロジェクト: migueldeicaza/esctest
 def test_REP_ExplicitParam(self):
   escio.Write("a")
   esccmd.REP(2)
   AssertScreenCharsInRectEqual(Rect(1, 1, 4, 1), ["aaa" + empty()])
コード例 #26
0
ファイル: el.py プロジェクト: unixfreaxjp/Therm
 def test_EL_Default(self):
   """Should erase to right of cursor."""
   self.prepare()
   esccmd.EL()
   AssertScreenCharsInRectEqual(Rect(1, 1, 10, 1),
                                [ "abcd" + 6 * NUL ])
コード例 #27
0
ファイル: decsel.py プロジェクト: migueldeicaza/esctest
 def test_DECSEL_2(self):
     """Should erase whole line."""
     self.prepare()
     esccmd.DECSEL(2)
     AssertScreenCharsInRectEqual(Rect(1, 1, 10, 1), [10 * empty()])
コード例 #28
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"])
コード例 #29
0
ファイル: rep.py プロジェクト: migueldeicaza/esctest
 def test_REP_DefaultParam(self):
   escio.Write("a")
   esccmd.REP()
   AssertScreenCharsInRectEqual(Rect(1, 1, 3, 1), ["aa" + empty()])
コード例 #30
0
 def test_SD_ExplicitParam(self):
     """SD should scroll the screen down by the number of lines given in the parameter."""
     self.prepare()
     esccmd.SD(2)
     expected_lines = [NUL * 5, NUL * 5, "abcde", "fghij", "klmno"]
     AssertScreenCharsInRectEqual(Rect(1, 1, 5, 5), expected_lines)