コード例 #1
0
ファイル: tests.py プロジェクト: jtruscott/ld27
    def test_make_box(self):
        box = buffer.Box(x=10, y=10, width=4, height=4)
        self.draw_box(box)

        #check it isnt blitting where it shouldnt
        self.check(9, 9, SPACE)
        self.check(11, 11, SPACE)
        self.check(15, 15, SPACE)

        box2 = buffer.Box(x=12,
                          y=12,
                          width=6,
                          height=6,
                          border_fg=colors.RED,
                          border_bg=colors.LIGHTRED,
                          interior_bg=colors.DARKGREY,
                          draw_left=False,
                          draw_top=False)

        self.draw_box(box2)
        self.check(12, 12, SPACE, bg=colors.DARKGREY)
        self.check(12, 13, SPACE)
        self.check(13, 12, SPACE)
        self.check(17,
                   17,
                   boxtypes.BoxDouble.br,
                   fg=colors.RED,
                   bg=colors.LIGHTRED)
コード例 #2
0
ファイル: tests.py プロジェクト: jtruscott/ld27
    def test_oob_blit(self):
        nullbuff = buffer.Buffer(x=10, y=10, width=0, height=0)
        nullbuff.draw()

        whitebox = buffer.Box(x=10,
                              y=10,
                              width=5,
                              height=5,
                              interior_bg=colors.WHITE)
        redbox = buffer.Box(x=10,
                            y=10,
                            width=5,
                            height=5,
                            interior_bg=colors.RED)
        bluebox = buffer.Box(x=10,
                             y=10,
                             width=5,
                             height=5,
                             interior_bg=colors.BLUE)
        self.draw_box(whitebox)

        redbox.x = -1
        redbox.y = -1
        redbox.draw()
        term.flip()

        self.check(0, 0, bg=colors.RED)
        self.check(self.width - 1, self.height - 1, bg=colors.BLACK)

        bluebox.x = self.width - 2
        bluebox.y = self.height - 2
        bluebox.draw()
        term.flip()
        self.check(self.width - 2, self.height - 2, ch=boxtypes.BoxDouble.tl)
        self.check(self.width - 1, self.height - 1, bg=colors.BLUE)
コード例 #3
0
ファイル: tests.py プロジェクト: jtruscott/ld27
    def test_nested(self):
        r = random.Random()
        r.seed(1356317227)

        root = buffer.Buffer(width=0, height=0)
        current = root
        all = []
        i = 0
        for sub in range(0, min(self.height, self.width), 4):
            h = self.height - sub
            w = self.width - sub
            i += 1
            b = buffer.Box(width=w,
                           height=h,
                           border_fg=(i % 16),
                           border_bg=(i + 1) % 8)
            current.children.append(b)
            all.append(b)
            current = b

        for i in range(30):
            root.draw()
            b = r.choice(all)
            for j in range(20):
                b.set_at(
                    x=r.randint(0, b.width - 1),
                    y=r.randint(0, b.height - 1),
                    char=chr(r.randint(0, 255)),
                    fg=int(r.triangular(0, 15)),
                    bg=int(r.triangular(0, 7)),
                )
            term.flip()
コード例 #4
0
ファイル: tests.py プロジェクト: jtruscott/ld27
 def test_set_at(self):
     box = buffer.Box(x=10, y=10, width=6, height=6)
     self.draw_box(box)
     log.debug(pprint.pformat(box._data))
     box.set_at(2, 2, '0', colors.LIGHTGREY)
     log.debug(pprint.pformat(box._data))
     box.draw()
     term.flip()
     self.check(12, 12, '0')
     self.check(13, 13, ' ')
     self.check(12, 13, ' ')
     self.check(13, 12, ' ')
コード例 #5
0
ファイル: tests.py プロジェクト: jtruscott/ld27
 def skip_test_permute(self):
     import cgitb
     try:
         for x in [0, 10]:
             for y in [0, 10]:
                 for width in [2, 10, 30]:
                     for height in [2, 10, 30]:
                         for border_fg in [
                                 colors.RED, colors.WHITE, colors.BLACK
                         ]:
                             for interior_fg in [
                                     colors.WHITE, colors.LIGHTGREY
                             ]:
                                 for border_bg in [
                                         colors.BLACK, colors.BLUE
                                 ]:
                                     for interior_bg in [
                                             colors.BLACK, colors.DARKGREY
                                     ]:
                                         for draw_left in [False, True]:
                                             for draw_right in [
                                                     False, True
                                             ]:
                                                 for draw_top in [
                                                         False, True
                                                 ]:
                                                     for draw_bottom in [
                                                             False, True
                                                     ]:
                                                         for boxtype in [
                                                                 boxtypes.
                                                                 BoxDouble,
                                                                 boxtypes.
                                                                 BoxSingle
                                                         ]:
                                                             self.draw_box(
                                                                 buffer.Box(
                                                                     x=x,
                                                                     y=y,
                                                                     width=
                                                                     width,
                                                                     height=
                                                                     height,
                                                                     border_fg
                                                                     =border_fg,
                                                                     interior_fg
                                                                     =interior_fg,
                                                                     border_bg
                                                                     =border_bg,
                                                                     interior_bg
                                                                     =interior_bg,
                                                                     draw_left
                                                                     =draw_left,
                                                                     draw_right
                                                                     =draw_right,
                                                                     draw_top
                                                                     =draw_top,
                                                                     draw_bottom
                                                                     =draw_bottom,
                                                                     boxtype=
                                                                     boxtype
                                                                 ))
     except:
         #resize changes the scrollback buffer size...
         term.resize(width=self.width, height=300)
         cgitb.Hook(format="text").handle()
         raise