예제 #1
0
    def test_redraw_scroll(self, cache_8x8, set_xy, clear_ram,
                           expand_node_entry, redraw_3):
        """Should be able to draw a scrolling list of nodes."""
        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00"
        self.assertEqual(self.vm.functions.redraw_scroll(), 0)
        self.vm.mocks.assert_has_calls([call.redraw_scroll(), call.redraw_3()])
        self.vm.mocks.reset_mock()

        # Six items, select the first
        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00aaaaabbbbbcccccdddddeeeeefffff"
        self.assertEqual(self.vm.functions.redraw_scroll(), 4)
        self.vm.mocks.assert_has_calls([
            call.redraw_scroll(),
            call.set_xy(0, 0),
            call.cache_8x8('\x13'),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 1),
            call.cache_8x8(' '),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 2),
            call.cache_8x8(' '),
            call.expand_node_entry('ccccc'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 3),
            call.cache_8x8('\x12'),
            call.expand_node_entry('ddddd'),
            call.cache_8x8(' abcdef -100dBm')
        ])
        self.vm.mocks.reset_mock()

        # Down to second
        self.vm.globals.G_SAVED_DISPLAY = "\x01\x00aaaaabbbbbcccccdddddeeeeefffff"
        self.assertEqual(self.vm.functions.redraw_scroll(), 4)
        self.vm.mocks.assert_has_calls([
            call.redraw_scroll(),
            call.set_xy(0, 0),
            call.cache_8x8('\x11'),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 1),
            call.cache_8x8('\x13'),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 2),
            call.cache_8x8(' '),
            call.expand_node_entry('ccccc'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 3),
            call.cache_8x8('\x12'),
            call.expand_node_entry('ddddd'),
            call.cache_8x8(' abcdef -100dBm')
        ])
        self.vm.mocks.reset_mock()

        # Down to third
        self.vm.globals.G_SAVED_DISPLAY = "\x02\x00aaaaabbbbbcccccdddddeeeeefffff"
        self.assertEqual(self.vm.functions.redraw_scroll(), 4)
        self.vm.mocks.assert_has_calls([
            call.redraw_scroll(),
            call.set_xy(0, 0),
            call.cache_8x8('\x11'),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 1),
            call.cache_8x8(' '),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 2),
            call.cache_8x8('\x13'),
            call.expand_node_entry('ccccc'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 3),
            call.cache_8x8('\x12'),
            call.expand_node_entry('ddddd'),
            call.cache_8x8(' abcdef -100dBm')
        ])
        self.vm.mocks.reset_mock()

        # Down to fourth
        self.vm.globals.G_SAVED_DISPLAY = "\x03\x00aaaaabbbbbcccccdddddeeeeefffff"
        self.assertEqual(self.vm.functions.redraw_scroll(), 4)
        self.vm.mocks.assert_has_calls([
            call.redraw_scroll(),
            call.set_xy(0, 0),
            call.cache_8x8('\x11'),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 1),
            call.cache_8x8(' '),
            call.expand_node_entry('ccccc'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 2),
            call.cache_8x8('\x13'),
            call.expand_node_entry('ddddd'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 3),
            call.cache_8x8('\x12'),
            call.expand_node_entry('eeeee'),
            call.cache_8x8(' abcdef -100dBm')
        ])
        self.vm.mocks.reset_mock()

        # Down to last
        self.vm.globals.G_SAVED_DISPLAY = "\x05\x00aaaaabbbbbcccccdddddeeeeefffff"
        self.assertEqual(self.vm.functions.redraw_scroll(), 4)
        self.vm.mocks.assert_has_calls([
            call.redraw_scroll(),
            call.set_xy(0, 0),
            call.cache_8x8('\x11'),
            call.expand_node_entry('ccccc'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 1),
            call.cache_8x8(' '),
            call.expand_node_entry('ddddd'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 2),
            call.cache_8x8(' '),
            call.expand_node_entry('eeeee'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 3),
            call.cache_8x8('\x13'),
            call.expand_node_entry('fffff'),
            call.cache_8x8(' abcdef -100dBm')
        ])
        self.vm.mocks.reset_mock()

        # Up one
        self.vm.globals.G_SAVED_DISPLAY = "\x04\x00aaaaabbbbbcccccdddddeeeeefffff"
        self.assertEqual(self.vm.functions.redraw_scroll(), 4)
        self.vm.mocks.assert_has_calls([
            call.redraw_scroll(),
            call.set_xy(0, 0),
            call.cache_8x8('\x11'),
            call.expand_node_entry('ccccc'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 1),
            call.cache_8x8(' '),
            call.expand_node_entry('ddddd'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 2),
            call.cache_8x8('\x13'),
            call.expand_node_entry('eeeee'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 3),
            call.cache_8x8('\x12'),
            call.expand_node_entry('fffff'),
            call.cache_8x8(' abcdef -100dBm')
        ])
        self.vm.mocks.reset_mock()

        # Up one
        self.vm.globals.G_SAVED_DISPLAY = "\x03\x00aaaaabbbbbcccccdddddeeeeefffff"
        self.assertEqual(self.vm.functions.redraw_scroll(), 4)
        self.vm.mocks.assert_has_calls([
            call.redraw_scroll(),
            call.set_xy(0, 0),
            call.cache_8x8('\x11'),
            call.expand_node_entry('ccccc'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 1),
            call.cache_8x8('\x13'),
            call.expand_node_entry('ddddd'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 2),
            call.cache_8x8(' '),
            call.expand_node_entry('eeeee'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 3),
            call.cache_8x8('\x12'),
            call.expand_node_entry('fffff'),
            call.cache_8x8(' abcdef -100dBm')
        ])
        self.vm.mocks.reset_mock()

        # Reduce list
        self.vm.globals.G_SAVED_DISPLAY = "\x03\x00aaaaabbbbbcccccdddddeeeee"
        self.assertEqual(self.vm.functions.redraw_scroll(), 4)
        self.vm.mocks.assert_has_calls([
            call.redraw_scroll(),
            call.set_xy(0, 0),
            call.cache_8x8('\x11'),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 1),
            call.cache_8x8(' '),
            call.expand_node_entry('ccccc'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 2),
            call.cache_8x8('\x13'),
            call.expand_node_entry('ddddd'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 3),
            call.cache_8x8('\x12'),
            call.expand_node_entry('eeeee'),
            call.cache_8x8(' abcdef -100dBm')
        ])
        self.vm.mocks.reset_mock()

        # Reduce list
        self.vm.globals.G_SAVED_DISPLAY = "\x03\x00aaaaabbbbbcccccddddd"
        self.assertEqual(self.vm.functions.redraw_scroll(), 4)
        self.vm.mocks.assert_has_calls([
            call.redraw_scroll(),
            call.set_xy(0, 0),
            call.cache_8x8('\x11'),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 1),
            call.cache_8x8(' '),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 2),
            call.cache_8x8(' '),
            call.expand_node_entry('ccccc'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 3),
            call.cache_8x8('\x13'),
            call.expand_node_entry('ddddd'),
            call.cache_8x8(' abcdef -100dBm')
        ])
        self.vm.mocks.reset_mock()

        # Reduce list
        self.vm.globals.G_SAVED_DISPLAY = "\x03\x00aaaaabbbbbccccc"
        self.assertEqual(self.vm.functions.redraw_scroll(), 4)
        self.vm.mocks.assert_has_calls([
            call.redraw_scroll(),
            call.set_xy(0, 0),
            call.cache_8x8('\x11'),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 1),
            call.cache_8x8(' '),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 2),
            call.cache_8x8('\x13'),
            call.expand_node_entry('ccccc'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 3),
            call.cache_8x8('                ')
        ])
        self.vm.mocks.reset_mock()

        # Reduce list
        self.vm.globals.G_SAVED_DISPLAY = "\x03\x00aaaaabbbbb"
        self.assertEqual(self.vm.functions.redraw_scroll(), 4)
        self.vm.mocks.assert_has_calls([
            call.redraw_scroll(),
            call.set_xy(0, 0),
            call.cache_8x8('\x11'),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 1),
            call.cache_8x8('\x13'),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 2),
            call.cache_8x8('                '),
            call.set_xy(0, 3),
            call.cache_8x8('                ')
        ])
        self.vm.mocks.reset_mock()

        # Reduce list
        self.vm.globals.G_SAVED_DISPLAY = "\x03\x00aaaaa"
        self.assertEqual(self.vm.functions.redraw_scroll(), 4)
        self.vm.mocks.assert_has_calls([
            call.redraw_scroll(),
            call.set_xy(0, 0),
            call.cache_8x8('\x13'),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8(' abcdef -100dBm'),
            call.set_xy(0, 1),
            call.cache_8x8('                '),
            call.set_xy(0, 2),
            call.cache_8x8('                '),
            call.set_xy(0, 3),
            call.cache_8x8('                ')
        ])
        self.vm.mocks.reset_mock()
예제 #2
0
    def test_redraw_8(self, cache_8x8, set_xy, clear_ram, expand_node_entry,
                      redraw_3):
        """Should be able to draw 0-8 nodes."""
        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00"
        self.assertEqual(self.vm.functions.redraw_8(), 0)
        self.vm.mocks.assert_has_calls([call.redraw_8(), call.redraw_3()])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00aaaaa"
        self.assertEqual(self.vm.functions.redraw_8(), 3)
        self.vm.mocks.assert_has_calls([
            call.redraw_8(),
            call.set_xy(0, 0),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 1),
            call.cache_8x8('       '),
            call.cache_8x8('  '),
            call.set_xy(0, 2),
            call.cache_8x8('       '),
            call.cache_8x8('  '),
            call.set_xy(0, 3),
            call.cache_8x8('       '),
            call.cache_8x8('  '),
            call.set_xy(9, 0),
            call.cache_8x8('       '),
            call.set_xy(9, 1),
            call.cache_8x8('       '),
            call.set_xy(9, 2),
            call.cache_8x8('       '),
            call.set_xy(9, 3),
            call.cache_8x8('       ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00aaaaabbbbb"
        self.assertEqual(self.vm.functions.redraw_8(), 3)
        self.vm.mocks.assert_has_calls([
            call.redraw_8(),
            call.set_xy(0, 0),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 1),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 2),
            call.cache_8x8('       '),
            call.cache_8x8('  '),
            call.set_xy(0, 3),
            call.cache_8x8('       '),
            call.cache_8x8('  '),
            call.set_xy(9, 0),
            call.cache_8x8('       '),
            call.set_xy(9, 1),
            call.cache_8x8('       '),
            call.set_xy(9, 2),
            call.cache_8x8('       '),
            call.set_xy(9, 3),
            call.cache_8x8('       ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00aaaaabbbbbccccc"
        self.assertEqual(self.vm.functions.redraw_8(), 3)
        self.vm.mocks.assert_has_calls([
            call.redraw_8(),
            call.set_xy(0, 0),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 1),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 2),
            call.expand_node_entry('ccccc'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 3),
            call.cache_8x8('       '),
            call.cache_8x8('  '),
            call.set_xy(9, 0),
            call.cache_8x8('       '),
            call.set_xy(9, 1),
            call.cache_8x8('       '),
            call.set_xy(9, 2),
            call.cache_8x8('       '),
            call.set_xy(9, 3),
            call.cache_8x8('       ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00aaaaabbbbbcccccddddd"
        self.assertEqual(self.vm.functions.redraw_8(), 3)
        self.vm.mocks.assert_has_calls([
            call.redraw_8(),
            call.set_xy(0, 0),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 1),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 2),
            call.expand_node_entry('ccccc'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 3),
            call.expand_node_entry('ddddd'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(9, 0),
            call.cache_8x8('       '),
            call.set_xy(9, 1),
            call.cache_8x8('       '),
            call.set_xy(9, 2),
            call.cache_8x8('       '),
            call.set_xy(9, 3),
            call.cache_8x8('       ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00aaaaabbbbbcccccdddddeeeee"
        self.assertEqual(self.vm.functions.redraw_8(), 3)
        self.vm.mocks.assert_has_calls([
            call.redraw_8(),
            call.set_xy(0, 0),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 1),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 2),
            call.expand_node_entry('ccccc'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 3),
            call.expand_node_entry('ddddd'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(9, 0),
            call.expand_node_entry('eeeee'),
            call.cache_8x8('abcdef#'),
            call.set_xy(9, 1),
            call.cache_8x8('       '),
            call.set_xy(9, 2),
            call.cache_8x8('       '),
            call.set_xy(9, 3),
            call.cache_8x8('       ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00aaaaabbbbbcccccdddddeeeeefffff"
        self.assertEqual(self.vm.functions.redraw_8(), 3)
        self.vm.mocks.assert_has_calls([
            call.redraw_8(),
            call.set_xy(0, 0),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 1),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 2),
            call.expand_node_entry('ccccc'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 3),
            call.expand_node_entry('ddddd'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(9, 0),
            call.expand_node_entry('eeeee'),
            call.cache_8x8('abcdef#'),
            call.set_xy(9, 1),
            call.expand_node_entry('fffff'),
            call.cache_8x8('abcdef#'),
            call.set_xy(9, 2),
            call.cache_8x8('       '),
            call.set_xy(9, 3),
            call.cache_8x8('       ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00aaaaabbbbbcccccdddddeeeeefffffggggg"
        self.assertEqual(self.vm.functions.redraw_8(), 3)
        self.vm.mocks.assert_has_calls([
            call.redraw_8(),
            call.set_xy(0, 0),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 1),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 2),
            call.expand_node_entry('ccccc'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 3),
            call.expand_node_entry('ddddd'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(9, 0),
            call.expand_node_entry('eeeee'),
            call.cache_8x8('abcdef#'),
            call.set_xy(9, 1),
            call.expand_node_entry('fffff'),
            call.cache_8x8('abcdef#'),
            call.set_xy(9, 2),
            call.expand_node_entry('ggggg'),
            call.cache_8x8('abcdef#'),
            call.set_xy(9, 3),
            call.cache_8x8('       ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00aaaaabbbbbcccccdddddeeeeefffffggggghhhhh"
        self.assertEqual(self.vm.functions.redraw_8(), 3)
        self.vm.mocks.assert_has_calls([
            call.redraw_8(),
            call.set_xy(0, 0),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 1),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 2),
            call.expand_node_entry('ccccc'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 3),
            call.expand_node_entry('ddddd'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(9, 0),
            call.expand_node_entry('eeeee'),
            call.cache_8x8('abcdef#'),
            call.set_xy(9, 1),
            call.expand_node_entry('fffff'),
            call.cache_8x8('abcdef#'),
            call.set_xy(9, 2),
            call.expand_node_entry('ggggg'),
            call.cache_8x8('abcdef#'),
            call.set_xy(9, 3),
            call.expand_node_entry('hhhhh'),
            call.cache_8x8('abcdef#')
        ])
        self.vm.mocks.reset_mock()
예제 #3
0
    def test_redraw_4(self, cache_8x8, set_xy, clear_ram, expand_node_entry,
                      redraw_3):
        """Should be able to draw 0-4 nodes."""
        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00"
        self.assertEqual(self.vm.functions.redraw_4(), 0)
        self.vm.mocks.assert_has_calls([call.redraw_4(), call.redraw_3()])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00aaaaa"
        self.assertEqual(self.vm.functions.redraw_4(), 1)
        self.vm.mocks.assert_has_calls([
            call.redraw_4(),
            call.set_xy(0, 0),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('* abcdef -100dBm'),
            call.set_xy(0, 1),
            call.cache_8x8('                '),
            call.set_xy(0, 2),
            call.cache_8x8('                '),
            call.set_xy(0, 3),
            call.cache_8x8('                ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00aaaaabbbbb"
        self.assertEqual(self.vm.functions.redraw_4(), 1)
        self.vm.mocks.assert_has_calls([
            call.redraw_4(),
            call.set_xy(0, 0),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('* abcdef -100dBm'),
            call.set_xy(0, 1),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8('* abcdef -100dBm'),
            call.set_xy(0, 2),
            call.cache_8x8('                '),
            call.set_xy(0, 3),
            call.cache_8x8('                ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00aaaaabbbbbccccc"
        self.assertEqual(self.vm.functions.redraw_4(), 1)
        self.vm.mocks.assert_has_calls([
            call.redraw_4(),
            call.set_xy(0, 0),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('* abcdef -100dBm'),
            call.set_xy(0, 1),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8('* abcdef -100dBm'),
            call.set_xy(0, 2),
            call.expand_node_entry('ccccc'),
            call.cache_8x8('* abcdef -100dBm'),
            call.set_xy(0, 3),
            call.cache_8x8('                ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00aaaaabbbbbcccccddddd"
        self.assertEqual(self.vm.functions.redraw_4(), 1)
        self.vm.mocks.assert_has_calls([
            call.redraw_4(),
            call.set_xy(0, 0),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('* abcdef -100dBm'),
            call.set_xy(0, 1),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8('* abcdef -100dBm'),
            call.set_xy(0, 2),
            call.expand_node_entry('ccccc'),
            call.cache_8x8('* abcdef -100dBm'),
            call.set_xy(0, 3),
            call.expand_node_entry('ddddd'),
            call.cache_8x8('* abcdef -100dBm')
        ])
        self.vm.mocks.reset_mock()
예제 #4
0
    def test_redraw_6(self, cache_8x8, set_xy, clear_ram, expand_node_entry,
                      redraw_3):
        """Should be able to draw 0-6 nodes."""
        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00"
        self.assertEqual(self.vm.functions.redraw_6(), 0)
        self.vm.mocks.assert_has_calls([call.redraw_6(), call.redraw_3()])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x04aaaaa"
        self.assertEqual(self.vm.functions.redraw_6(), 2)
        self.vm.mocks.assert_has_calls([
            call.redraw_6(),
            call.set_xy(0, 0),
            call.cache_8x8('Neighbors:    \x05\x01'),
            call.set_xy(0, 1),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 2),
            call.cache_8x8('       '),
            call.cache_8x8('  '),
            call.set_xy(0, 3),
            call.cache_8x8('       '),
            call.cache_8x8('  '),
            call.set_xy(9, 1),
            call.cache_8x8('       '),
            call.set_xy(9, 2),
            call.cache_8x8('       '),
            call.set_xy(9, 3),
            call.cache_8x8('       ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x05aaaaabbbbb"
        self.assertEqual(self.vm.functions.redraw_6(), 2)
        self.vm.mocks.assert_has_calls([
            call.redraw_6(),
            call.set_xy(0, 0),
            call.cache_8x8('Neighbors:    \x06\x01'),
            call.set_xy(0, 1),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 2),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 3),
            call.cache_8x8('       '),
            call.cache_8x8('  '),
            call.set_xy(9, 1),
            call.cache_8x8('       '),
            call.set_xy(9, 2),
            call.cache_8x8('       '),
            call.set_xy(9, 3),
            call.cache_8x8('       ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x06aaaaabbbbbccccc"
        self.assertEqual(self.vm.functions.redraw_6(), 2)
        self.vm.mocks.assert_has_calls([
            call.redraw_6(),
            call.set_xy(0, 0),
            call.cache_8x8('Neighbors:    \x07\x01'),
            call.set_xy(0, 1),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 2),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 3),
            call.expand_node_entry('ccccc'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(9, 1),
            call.cache_8x8('       '),
            call.set_xy(9, 2),
            call.cache_8x8('       '),
            call.set_xy(9, 3),
            call.cache_8x8('       ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x07aaaaabbbbbcccccddddd"
        self.assertEqual(self.vm.functions.redraw_6(), 2)
        self.vm.mocks.assert_has_calls([
            call.redraw_6(),
            call.set_xy(0, 0),
            call.cache_8x8('Neighbors:    \x07\x08'),
            call.set_xy(0, 1),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 2),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 3),
            call.expand_node_entry('ccccc'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(9, 1),
            call.expand_node_entry('ddddd'),
            call.cache_8x8('abcdef#'),
            call.set_xy(9, 2),
            call.cache_8x8('       '),
            call.set_xy(9, 3),
            call.cache_8x8('       ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x08aaaaabbbbbcccccdddddeeeee"
        self.assertEqual(self.vm.functions.redraw_6(), 2)
        self.vm.mocks.assert_has_calls([
            call.redraw_6(),
            call.set_xy(0, 0),
            call.cache_8x8('Neighbors:    \x07\x09'),
            call.set_xy(0, 1),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 2),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 3),
            call.expand_node_entry('ccccc'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(9, 1),
            call.expand_node_entry('ddddd'),
            call.cache_8x8('abcdef#'),
            call.set_xy(9, 2),
            call.expand_node_entry('eeeee'),
            call.cache_8x8('abcdef#'),
            call.set_xy(9, 3),
            call.cache_8x8('       ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x09aaaaabbbbbcccccdddddeeeeefffff"
        self.assertEqual(self.vm.functions.redraw_6(), 2)
        self.vm.mocks.assert_has_calls([
            call.redraw_6(),
            call.set_xy(0, 0),
            call.cache_8x8('Neighbors:    \x07\x0a'),
            call.set_xy(0, 1),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 2),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(0, 3),
            call.expand_node_entry('ccccc'),
            call.cache_8x8('abcdef#'),
            call.cache_8x8('  '),
            call.set_xy(9, 1),
            call.expand_node_entry('ddddd'),
            call.cache_8x8('abcdef#'),
            call.set_xy(9, 2),
            call.expand_node_entry('eeeee'),
            call.cache_8x8('abcdef#'),
            call.set_xy(9, 3),
            call.expand_node_entry('fffff'),
            call.cache_8x8('abcdef#')
        ])
        self.vm.mocks.reset_mock()
예제 #5
0
    def test_redraw_3(self, cache_8x8, set_xy, clear_ram, expand_node_entry):
        """Should be able to draw 0-3 nodes."""
        self.vm.globals.G_SAVED_DISPLAY = "\x00\x00"
        self.assertEqual(self.vm.functions.redraw_3(), 0)
        self.vm.mocks.assert_has_calls([
            call.redraw_3(),
            call.set_xy(0, 0),
            call.cache_8x8('Neighbors:    \x00\x01'),
            call.set_xy(0, 1),
            call.cache_8x8('                '),
            call.set_xy(0, 2),
            call.cache_8x8('   (none yet)   '),
            call.set_xy(0, 3),
            call.cache_8x8('                ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x01aaaaa"
        self.assertEqual(self.vm.functions.redraw_3(), 0)
        self.vm.mocks.assert_has_calls([
            call.redraw_3(),
            call.set_xy(0, 0),
            call.cache_8x8('Neighbors:    \x02\x01'),
            call.set_xy(0, 1),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('* abcdef -100dBm'),
            call.set_xy(0, 2),
            call.cache_8x8('                '),
            call.set_xy(0, 3),
            call.cache_8x8('                ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x02aaaaabbbbb"
        self.assertEqual(self.vm.functions.redraw_3(), 0)
        self.vm.mocks.assert_has_calls([
            call.redraw_3(),
            call.set_xy(0, 0),
            call.cache_8x8('Neighbors:    \x03\x01'),
            call.set_xy(0, 1),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('* abcdef -100dBm'),
            call.set_xy(0, 2),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8('* abcdef -100dBm'),
            call.set_xy(0, 3),
            call.cache_8x8('                ')
        ])
        self.vm.mocks.reset_mock()

        self.vm.globals.G_SAVED_DISPLAY = "\x00\x03aaaaabbbbbccccc"
        self.assertEqual(self.vm.functions.redraw_3(), 0)
        self.vm.mocks.assert_has_calls([
            call.redraw_3(),
            call.set_xy(0, 0),
            call.cache_8x8('Neighbors:    \x04\x01'),
            call.set_xy(0, 1),
            call.expand_node_entry('aaaaa'),
            call.cache_8x8('* abcdef -100dBm'),
            call.set_xy(0, 2),
            call.expand_node_entry('bbbbb'),
            call.cache_8x8('* abcdef -100dBm'),
            call.set_xy(0, 3),
            call.expand_node_entry('ccccc'),
            call.cache_8x8('* abcdef -100dBm')
        ])