Ejemplo n.º 1
0
def GetWindowPosition():
    """Returns a Point giving the window's origin in screen pixels."""
    esccmd.XTERM_WINOPS(esccmd.WINOP_REPORT_WINDOW_POSITION)
    params = escio.ReadCSI("t")
    AssertTrue(params[0] == 3)
    AssertTrue(len(params) >= 3)
    return Point(params[1], params[2])
Ejemplo n.º 2
0
 def handleDAResponse(self):
   params = escio.ReadCSI('c', expected_prefix='?')
   if escargs.args.expected_terminal == "xterm":
     # This is for a default build. There are various options that could
     # change this, both compile-time and run-time.  XTerm's control sequences
     # document lists the ones it may return.  For a more comprehensive list,
     # see DEC STD 070, page 4.
     if escargs.args.max_vt_level == 5:
       expected = [65, 1, 2, 6, 9, 15, 16, 17, 18, 21, 22, 28, 29]
     elif escargs.args.max_vt_level == 4:
       expected = [64, 1, 2, 6, 9, 15, 16, 17, 18, 21, 22, 28, 29]
     elif escargs.args.max_vt_level == 3:
       expected = [63, 1, 2, 6, 9, 15, 22, 29]
     elif escargs.args.max_vt_level == 2:
       expected = [62, 1, 2, 6, 9, 15, 22, 29]
     elif escargs.args.max_vt_level == 1:
       expected = [1, 2] # xterm extension (VT100)
     else:
       expected = [0] # xterm extension
   elif escargs.args.expected_terminal == "iTerm2":
     # TODO:  Determine which VT levels are completely supported and add 6,
     # 62, 63, or 64.
     # I believe 18 means we support DECSTB and DECSLRM but I can't find any
     # evidence to substantiate this belief.
     expected = [1, 2, 18, 22]
   # Our interest in the primary device attributes is to ensure that the
   # terminal asserts that it supports the features we need.  It may support
   # other features; without a detailed analysis we cannot determine which
   # additional features are inappropriate, e.g, rectangular editing on VT320.
   AssertGE(len(params), len(expected))
   AssertEQ(params[0], expected[0])
   for param in expected:
     AssertTrue(param in params)
Ejemplo n.º 3
0
    def test_DECDSR_DSRMultipleSessionStatus(self):
        """Checks on the status of multiple sessons. SSU refers to some proprietary
    DEC technology that multilexes multiple sessions over a single link using
    the "TDSMP" protocol. Lots of detail here:
    http://paperlined.org/apps/terminals/control_characters/TDSMP.html

    It's safe to assume TDSMP is dead and buried.

    CSI ? 80 ; Ps2 n
      Multiple sessions are operating using the session support utility (SSU)
      and the current SSU state is enabled. Ps2 indicates the maximum number of
      sessions available. Default: Ps2 = 2
    CSI ? 81 ; Ps2 n
      The terminal is currently configured for multiple sessions using SSU but
      the current SSU state is pending. Ps2 indicates the maximum number of
      sessions available. Default: Ps2 = 2
    CSI ? 83 n
      The terminal is not configured for multiple-session operation.
    CSI ? 87 n
      Multiple sessions are operating using a separate physical line for each
      session, not SSU."""
        esccmd.DECDSR(esccmd.DSRMultipleSessionStatus)
        params = escio.ReadCSI('n', expected_prefix='?')
        AssertEQ(len(params), 1)
        # 83 and 87 both seem like reasonable responses for a terminal that
        # supports tabs or windows.
        AssertTrue(params[0] in [83, 87])
Ejemplo n.º 4
0
def GetWindowSizePixels():
    """Returns a Size giving the window's size in pixels."""
    esccmd.XTERM_WINOPS(esccmd.WINOP_REPORT_WINDOW_SIZE_PIXELS)
    params = escio.ReadCSI("t")
    AssertTrue(params[0] == 4)
    AssertTrue(len(params) >= 3)
    return Size(params[2], params[1])
Ejemplo n.º 5
0
    def doLocatorStatusTest(self, code):
        """I couldn't find docs on these codes outside xterm. 53 and 55 seem to be
    the same. Returns 50 if no locator, 53 if available."""
        esccmd.DECDSR(code)
        params = escio.ReadCSI('n', expected_prefix='?')

        AssertEQ(len(params), 1)
        AssertTrue(params[0] in [50, 53, 55])
Ejemplo n.º 6
0
def GetScreenSize():
    """Return the terminal's screen-size in characters.

  The size is reported for the terminal's character-cell window,
  which is smaller than the shell-window."""
    esccmd.XTERM_WINOPS(esccmd.WINOP_REPORT_TEXT_AREA_CHARS)
    params = escio.ReadCSI("t")
    return Size(params[2], params[1])
Ejemplo n.º 7
0
    def test_DECDSR_DECMSR(self):
        """Get space available for macros. This test assumes it's always 0."""
        esccmd.DECDSR(esccmd.DECMSR)
        params = escio.ReadCSI('*{')

        # Assume the terminal being tested doesn't support macros. May need to add
        # code some day for a more capable terminal.
        AssertEQ(len(params), 1)
        AssertEQ(params[0], 0)
Ejemplo n.º 8
0
    def test_DECID_8bit(self):
        escio.use8BitControls = True
        escio.Write(S8C1T)

        esccmd.DECID()
        params = escio.ReadCSI("c", expected_prefix="?")
        AssertTrue(len(params) > 0)

        escio.Write(S7C1T)
        escio.use8BitControls = False
Ejemplo n.º 9
0
 def getVTLevel(self):
     esccmd.DA2()
     params = escio.ReadCSI('c', expected_prefix='>')
     myLevel = params[0]
     if myLevel < 18:
         return 2
     elif myLevel <= 24:
         return 3
     else:
         return 4
Ejemplo n.º 10
0
    def test_DECDSR_LocatorType(self):
        """Get the type of the locator (pointing device.)
    0 - unknown (not documented)
    1 - mouse
    2 - tablet"""
        esccmd.DECDSR(esccmd.DSRLocatorId)
        params = escio.ReadCSI('n', expected_prefix='?')

        AssertEQ(params[0], 57)
        AssertTrue(params[1] in [0, 1, 2])
Ejemplo n.º 11
0
 def handleDA2Response(self):
     params = escio.ReadCSI('c', expected_prefix='>')
     if escargs.args.expected_terminal == "xterm":
         AssertGE(params[0], 41)
         AssertGE(params[1], 314)
         AssertEQ(len(params), 3)
     elif escargs.args.expected_terminal == "iTerm2":
         AssertEQ(params[0], 0)
         AssertEQ(params[1], 95)
         AssertEQ(len(params), 2)
Ejemplo n.º 12
0
def GetWindowPosition():
    """Returns a Point giving the window's origin in screen pixels.

  This is the upper-left corner of xterm's shell-window, and is usually
  not the same as the upper-left corner of the terminal's character cell
  grid."""
    esccmd.XTERM_WINOPS(esccmd.WINOP_REPORT_WINDOW_POSITION)
    params = escio.ReadCSI("t")
    AssertTrue(params[0] == 3)
    AssertTrue(len(params) >= 3)
    return Point(params[1], params[2])
Ejemplo n.º 13
0
 def handleDAResponse(self):
     params = escio.ReadCSI('c', expected_prefix='?')
     if escargs.args.expected_terminal == "xterm":
         # This is for a default build. There are various options that could
         # change this (disabling ReGIS, etc.)
         expected = [64, 1, 2, 6, 9, 15, 18, 21, 22]
     elif escargs.args.expected_terminal == "iTerm2":
         # TODO: Determine which VT levels are completely supported an add 6, 62, 63, or 64.
         # I believe 18 means we support DECSTB and DECSLRM but I can't find any
         # evidence to substantiate this belief.
         expected = [1, 2, 18, 22]
     AssertEQ(params, expected)
Ejemplo n.º 14
0
 def test_DECDSR_DSRUDKLocked(self):
     """Tests if user-defined keys are locked or unlocked. The allowed repsonses are:
   CSI ? Pn n
 Where Pn is:
   20 - Unlocked
   21 - Locked
 This test simply ensures the value is legal. It should be extended to
 ensure that when locked UDKs are not settable, and when unlocked that UDKs
 are settable."""
     esccmd.DECDSR(esccmd.DSRUDKLocked)
     params = escio.ReadCSI('n', expected_prefix='?')
     AssertEQ(len(params), 1)
     AssertTrue(params[0] in [20, 21])
Ejemplo n.º 15
0
    def test_DSCSCL_Level3_SupportsDECRQMDoesntSupportDECSLRM(self):
        # Set level 3 conformance
        esccmd.DECSCL(63, 1)

        # Make sure DECRQM is ok.
        esccmd.DECRQM(esccmd.IRM, DEC=False)
        escio.ReadCSI('$y')

        # Make sure DECSLRM fails.
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(5, 6)
        esccmd.CUP(Point(5, 1))
        escio.Write("abc")
        AssertEQ(GetCursorPosition().x(), 8)
Ejemplo n.º 16
0
def CanQueryShellSize():
    """Determine if the terminal responds to a request for shell-window size vs
  text-window size.

  xterm has two windows of interest:
  a) the text-window
  b) the shell-window (i.e., outer window).

  The shell-window includes the title and other decorations.  Unless those are
  suppressed (an option in some window managers), it will be larger than the
  terminal's character-cell window.  In any case, it also has a border which is
  normally present.

  The window operations report for the window-size in pixels was added to xterm
  to provide an alternate way to measure the text-window (and indirectly, the
  font size).  That is the default operation.  Alternatively, the size of the
  shell window can be returned."""
    global gCanQueryShellSize
    if gCanQueryShellSize < 0:
        gCanQueryShellSize = 0
        # check for the default operation
        esccmd.XTERM_WINOPS(esccmd.WINOP_REPORT_WINDOW_SIZE_PIXELS)
        params = escio.ReadCSI("t")
        if params[0] == 4 and len(params) >= 3:
            # TODO: compare size_1 with result from text-window size
            # If it is larger, then that's a special case.
            size_1 = Size(params[2], params[1])
            gCanQueryShellSize = 1
            # check for the window-shell operation
            esccmd.XTERM_WINOPS(esccmd.WINOP_REPORT_WINDOW_SIZE_PIXELS, 2)
            params = escio.ReadCSI("t")
            if params[0] == 4 and len(params) >= 3:
                size_2 = Size(params[2], params[1])
                if size_2.height() > size_1.height() and \
                   size_2.width() > size_1.width():
                    gCanQueryShellSize = 2
    return gCanQueryShellSize
Ejemplo n.º 17
0
 def test_DECDSR_DSRPrinterPort(self):
     """Requests printer status. The allowed responses are:
     CSI ? Pn n
   Where Pn is:
     10 - Ready
     11 - Not ready
     13 - No printer
     18 - Busy
     19 - Assigned to other session.
   There's no way for the test to know what the actual printer status is,
   but the response should be legal."""
     esccmd.DECDSR(esccmd.DSRPrinterPort)
     params = escio.ReadCSI('n', expected_prefix='?')
     AssertEQ(len(params), 1)
     AssertTrue(params[0] in [10, 11, 13, 18, 19])
Ejemplo n.º 18
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)
Ejemplo n.º 19
0
def GetCharSizePixels():
    """Returns a Size giving the font's character-size in pixels.

  While xterm can be told to change its font, none of these tests exercise
  that feature.  We cache a value to improve performance.
  """
    global gCharSizePixels
    if gCharSizePixels.height() == 0:
        esccmd.XTERM_WINOPS(esccmd.WINOP_REPORT_CHAR_SIZE_PIXELS)
        params = escio.ReadCSI("t")
        AssertTrue(params[0] == 6)
        AssertTrue(len(params) >= 3)
        gCharSizePixels = Size(params[2], params[1])
        LogDebug("size of CHARS " + str(gCharSizePixels.height()) + "x" +
                 str(gCharSizePixels.width()))
    return gCharSizePixels
Ejemplo n.º 20
0
 def test_DECDSR_DSRKeyboard(self):
     """Gets info about the keyboard. The response is:
   CSI ? 27; Pn; Pst; Ptyp n
 Where
   Pn - Keyboard language
     0 - Not known
     1 - North American
     2...19, 22, 28, 29...31, 33, 35, 36, 38...40 - Various other legal values
   Pst - Keyboard status - Per the VT 510 manual, this is level 4 only.
         However, it is documented in "VT330/VT340 Programmer Reference Manual
         Volume 1: Text Programming".
     0 - Ready
     3 - No keyboard
     8 - Keyboard busy in other session
   Ptyp - Keyboard type - VT level 4 only
     0 - LK201  # DEC 420
     1 - LK401  # DEC 420
     4 - LK450  # DEC 510
     5 - PCXAL  # DEC 510"""
     # First get the VT level with a DA2
     myLevel = self.getVTLevel()
     esccmd.DECDSR(esccmd.DSRKeyboard)
     params = escio.ReadCSI('n', expected_prefix='?')
     if myLevel <= 2:
         # VT240 or earlier
         AssertEQ(len(params), 2)
     elif myLevel == 3:
         # VT340 or earlier
         AssertEQ(len(params), 3)
     else:
         # VT420+
         AssertEQ(len(params), 4)
     AssertEQ(params[0], 27)
     if len(params) > 1:
         AssertTrue(params[1] in [
             0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
             18, 19, 22, 28, 29, 30, 31, 33, 35, 36, 38, 39, 40
         ])
     if len(params) > 2:
         AssertTrue(params[2] in [0, 3, 8])
     if len(params) > 3:
         AssertTrue(params[3] in [0, 1, 4, 5])
Ejemplo n.º 21
0
def GetScreenSizePixels():
    """Returns a Size giving the screen's size in pixels.

  The "screen" refers to the X display on which xterm is running.
  Because that does not change as a result of these tests, we
  cache a value to help with performance."""
    global gScreenSizePixels
    if gScreenSizePixels.height() == 0:
        if escargs.args.expected_terminal == "xterm":
            esccmd.XTERM_WINOPS(esccmd.WINOP_REPORT_SCREEN_SIZE_PIXELS)
            params = escio.ReadCSI("t")
            AssertTrue(params[0] == 5)
            AssertTrue(len(params) >= 3)
            gScreenSizePixels = Size(params[2], params[1])
        else:
            # iTerm2 doesn't support esccmd.WINOP_REPORT_SCREEN_SIZE_PIXELS so just fake it.
            gScreenSizePixels = Size(1024, 768)
        LogDebug("size of SCREEN " + str(gScreenSizePixels.height()) + "x" +
                 str(gScreenSizePixels.width()))
    return gScreenSizePixels
Ejemplo n.º 22
0
 def handleDA2Response(self):
     params = escio.ReadCSI('c', expected_prefix='>')
     if escargs.args.expected_terminal == "xterm":
         if esc.vtLevel == 5:
             AssertEQ(params[0], 64)
         elif esc.vtLevel == 4:
             AssertEQ(params[0], 41)
         elif esc.vtLevel == 3:
             AssertEQ(params[0], 24)
         elif esc.vtLevel == 2:
             AssertEQ(params[0], 1)
         elif esc.vtLevel == 2:
             AssertEQ(params[0], 0)
         AssertGE(999, params[1])
         AssertGE(params[1], 314)
         AssertEQ(len(params), 3)
     elif escargs.args.expected_terminal == "iTerm2":
         AssertEQ(params[0], 0)
         AssertEQ(params[1], 95)
         AssertEQ(len(params), 3)
Ejemplo n.º 23
0
    def test_DECDSR_DECXCPR(self):
        """DECXCPR reports the cursor position. Response is:
    CSI ? Pl ; Pc ; Pr R
      Pl - line
      Pc - column
      Pr - page"""
        # First, get the VT level.
        myLevel = self.getVTLevel()

        esccmd.CUP(Point(5, 6))
        esccmd.DECDSR(esccmd.DECXCPR)
        params = escio.ReadCSI('R', expected_prefix='?')

        if myLevel >= 4:
            # VT400+
            # Last arg is page, which is always 1 (at least in xterm, and I think
            # that's reasonable in all modern terminals, which won't have a direct
            # notion of a page.)
            AssertEQ(params, [6, 5, 1])
        else:
            AssertEQ(params, [6, 5])
Ejemplo n.º 24
0
 def handleDAResponse(self):
     params = escio.ReadCSI('c', expected_prefix='?')
     if escargs.args.expected_terminal == "xterm":
         # This is for a default build. There are various options that could
         # change this, both compile-time and run-time.
         if escargs.args.max_vt_level == 5:
             expected = [65, 1, 2, 6, 9, 15, 18, 21, 22, 29]
         elif escargs.args.max_vt_level == 4:
             expected = [64, 1, 2, 6, 9, 15, 18, 21, 22, 29]
         elif escargs.args.max_vt_level == 3:
             expected = [63, 1, 2, 6, 9, 15, 22, 29]
         elif escargs.args.max_vt_level == 2:
             expected = [62, 1, 2, 6, 9, 15, 22, 29]
         elif escargs.args.max_vt_level == 1:
             expected = [1, 2]  # xterm extension (VT100)
         else:
             expected = [0]  # xterm extension
     elif escargs.args.expected_terminal == "iTerm2":
         # TODO: Determine which VT levels are completely supported an add 6, 62, 63, or 64.
         # I believe 18 means we support DECSTB and DECSLRM but I can't find any
         # evidence to substantiate this belief.
         expected = [1, 2, 18, 22]
     AssertEQ(params, expected)
Ejemplo n.º 25
0
 def requestAnsiMode(self, mode):
     esccmd.DECRQM(mode, DEC=False)
     return escio.ReadCSI('$y')
Ejemplo n.º 26
0
 def requestDECMode(self, mode):
     esccmd.DECRQM(mode, DEC=True)
     return escio.ReadCSI('$y', '?')
Ejemplo n.º 27
0
def GetIsIconified():
    esccmd.XTERM_WINOPS(esccmd.WINOP_REPORT_WINDOW_STATE)
    params = escio.ReadCSI("t")
    AssertTrue(params[0] in [1, 2], "Params are " + str(params))
    return params[0] == 2
Ejemplo n.º 28
0
def GetCursorPosition():
    esccmd.DSR(esccmd.DSRCPR, suppressSideChannel=True)
    params = escio.ReadCSI("R")
    return Point(int(params[1]), int(params[0]))
Ejemplo n.º 29
0
def GetDisplaySize():
    esccmd.XTERM_WINOPS(esccmd.WINOP_REPORT_SCREEN_SIZE_CHARS)
    params = escio.ReadCSI("t")
    return Size(params[2], params[1])
Ejemplo n.º 30
0
 def test_DECDSR_DSRDataIntegrity(self):
     """Check for link errors. Should always report OK."""
     esccmd.DECDSR(esccmd.DSRIntegrityReport)
     params = escio.ReadCSI('n', expected_prefix='?')
     AssertEQ(len(params), 1)
     AssertEQ(params[0], 70)