コード例 #1
0
def test_ensure_width():
    screen = HistoryScreen(5, 5, pages=10)

    for idx in xrange(len(screen) * 5):
        map(screen.draw, unicode(idx))
        screen.linefeed()

    assert screen.display == ["21   ", "22   ", "23   ", "24   ", "     "]

    # a) shrinking the screen, expecting the lines displayed to
    #    be truncated.
    screen.resize(5, 2)
    screen.page_up()

    assert all(len(l) is not 2 for l in screen.history.top)
    assert all(len(l) is 2 for l in screen.history.bottom)
    assert screen.display == ["18", "19", "20", "21", "22"]

    # b) expading the screen, expecting the lines displayed to
    #    be filled with whitespace characters.
    screen.resize(5, 10)
    screen.page_down()

    assert all(len(l) is 10 for l in list(screen.history.top)[-3:])
    assert all(len(l) is not 10 for l in screen.history.bottom)
    assert screen.display == [
        "21        ", "22        ", "23        ", "24        ", "          "
    ]
コード例 #2
0
ファイル: test_history.py プロジェクト: amarao/vt102
def test_ensure_width():
    screen = HistoryScreen(5, 5, pages=10)

    for idx in xrange(len(screen) * 5):
        map(screen.draw, unicode(idx))
        screen.linefeed()

    assert screen.display == [
        "21   ",
        "22   ",
        "23   ",
        "24   ",
        "     "
    ]

    # a) shrinking the screen, expecting the lines displayed to
    #    be truncated.
    screen.resize(5, 2)
    screen.page_up()

    assert all(len(l) is not 2 for l in screen.history.top)
    assert all(len(l) is 2 for l in screen.history.bottom)
    assert screen.display == [
        "18",
        "19",
        "20",
        "21",
        "22"
    ]

    # b) expading the screen, expecting the lines displayed to
    #    be filled with whitespace characters.
    screen.resize(5, 10)
    screen.page_down()

    assert all(len(l) is 10 for l in list(screen.history.top)[-3:])
    assert all(len(l) is not 10 for l in screen.history.bottom)
    assert screen.display == [
        "21        ",
        "22        ",
        "23        ",
        "24        ",
        "          "
    ]
コード例 #3
0
def test_page_down():
    screen = HistoryScreen(5, 5, pages=10)

    # Once again filling the screen with line numbers, but this time,
    # we need them to span on multiple lines.
    for idx in xrange(len(screen) * 5):
        map(screen.draw, unicode(idx))
        screen.linefeed()

    assert screen.history.top
    assert not screen.history.bottom
    assert screen.page == 5
    assert screen.display == ["21   ", "22   ", "23   ", "24   ", "     "]

    # a) page up -- page down.
    screen.page_up()
    screen.page_down()
    assert screen.history.top
    assert not screen.history.bottom
    assert screen.page == 5
    assert screen.display == ["21   ", "22   ", "23   ", "24   ", "     "]

    # b) double page up -- page down.
    screen.page_up()
    screen.page_up()
    screen.page_down()
    assert screen.page == 4
    assert screen.history.top
    assert chars(screen.history.bottom) == ["23   ", "24   ", "     "]

    assert screen.display == ["18   ", "19   ", "20   ", "21   ", "22   "]

    # c) double page up -- double page down
    screen.page_up()
    screen.page_up()
    screen.page_down()
    screen.page_down()
    assert screen.page == 4
    assert screen.display == ["18   ", "19   ", "20   ", "21   ", "22   "]
コード例 #4
0
ファイル: test_history.py プロジェクト: amarao/vt102
def test_page_down():
    screen = HistoryScreen(5, 5, pages=10)

    # Once again filling the screen with line numbers, but this time,
    # we need them to span on multiple lines.
    for idx in xrange(len(screen) * 5):
        map(screen.draw, unicode(idx))
        screen.linefeed()

    assert screen.history.top
    assert not screen.history.bottom
    assert screen.page == 5
    assert screen.display == [
        "21   ",
        "22   ",
        "23   ",
        "24   ",
        "     "
    ]

    # a) page up -- page down.
    screen.page_up()
    screen.page_down()
    assert screen.history.top
    assert not screen.history.bottom
    assert screen.page == 5
    assert screen.display == [
        "21   ",
        "22   ",
        "23   ",
        "24   ",
        "     "
    ]

    # b) double page up -- page down.
    screen.page_up()
    screen.page_up()
    screen.page_down()
    assert screen.page == 4
    assert screen.history.top
    assert chars(screen.history.bottom) == [
        "23   ",
        "24   ",
        "     "
    ]

    assert screen.display == [
        "18   ",
        "19   ",
        "20   ",
        "21   ",
        "22   "
    ]


    # c) double page up -- double page down
    screen.page_up()
    screen.page_up()
    screen.page_down()
    screen.page_down()
    assert screen.page == 4
    assert screen.display == [
        "18   ",
        "19   ",
        "20   ",
        "21   ",
        "22   "
    ]