示例#1
0
文件: hvp.py 项目: AndiDog/iTerm2
  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())
示例#2
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())
示例#3
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."""
    if escargs.args.expected_terminal == "xterm":
      maximum_size = GetScreenSizePixels()
      original_size = GetWindowSizePixels()

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

      # 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())
      self.DelayAfterResize()
    else:
      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())
示例#4
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())
示例#5
0
文件: vpa.py 项目: AndiDog/iTerm2
  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())
示例#6
0
文件: decstbm.py 项目: AndiDog/iTerm2
  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())
示例#7
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())
示例#8
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))
示例#9
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", "rs"])
示例#10
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())
示例#11
0
 def test_XtermWinops_MaximizeWindow_Horizontally(self):
   display_size = GetDisplaySize()
   original_size = GetScreenSize()
   expected_size = Size(width=display_size.width(),
                        height=original_size.height())
   esccmd.XTERM_WINOPS(esccmd.WINOP_MAXIMIZE, esccmd.WINOP_MAXIMIZE_H)
   AssertEQ(GetScreenSize(), expected_terminal)
示例#12
0
  def test_XtermWinops_ResizeChars_DefaultHeight(self):
    size = GetScreenSize()
    desired_size = Size(20, size.height())

    esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_CHARS,
                            None,
                            desired_size.width())
    AssertEQ(GetScreenSize(), desired_size)
示例#13
0
文件: deccra.py 项目: AndiDog/iTerm2
  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" ])
示例#14
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())
示例#15
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", empty()])

        # Verify the cursor is at the last line on the page.
        AssertEQ(GetCursorPosition().y(), size.height())
示例#16
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())
示例#17
0
文件: decstbm.py 项目: AndiDog/iTerm2
  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())
示例#18
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)])
示例#19
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) ])
示例#20
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)
示例#21
0
    def test_XtermWinops_ResizeChars_ZeroWidth(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(maximum_size.width(), original_size.height())
        else:
            desired_size = Size(maximum_size.width(), 21)

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

        limit = self.GetCharErrorLimit()
        limit = Size(limit.width(), 0)
        self.CheckActualSizeChars(desired_size, limit)
示例#22
0
文件: decaln.py 项目: AndiDog/iTerm2
 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" ])
示例#23
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)])
示例#24
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) ])
示例#25
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"])
示例#26
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"])
示例#27
0
文件: deccra.py 项目: AndiDog/iTerm2
  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" ])
示例#28
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])
示例#29
0
文件: decstbm.py 项目: AndiDog/iTerm2
  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 ])