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()
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()
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()
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()
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') ])
def test_display(self, cycle_batt_msg, redraw_scroll, redraw_8, redraw_6, redraw_4, redraw_3): """Should call the appropriate display method""" # Increasing display mode for i in xrange(10): self.vm.functions.display("HH" + "".join( str(j) * 5 for j in xrange(i + 1))) self.vm.mocks.assert_has_calls([ call.display('HH00000'), call.redraw_3(), call.display('HH0000011111'), call.redraw_3(), call.display('HH000001111122222'), call.redraw_3(), call.display('HH00000111112222233333'), call.redraw_4(), call.display('HH0000011111222223333344444'), call.redraw_6(), call.display('HH000001111122222333334444455555'), call.redraw_6(), call.display('HH00000111112222233333444445555566666'), call.redraw_8(), call.display('HH0000011111222223333344444555556666677777'), call.redraw_8(), call.display('HH000001111122222333334444455555666667777788888'), call.redraw_scroll(), call.display( 'HH00000111112222233333444445555566666777778888899999'), call.redraw_scroll() ]) self.vm.mocks.reset_mock() # Decreasing display mode self.vm.functions.display("HH0000011111222223333344444555556666677777") self.vm.functions.display_on_1s(1000) self.vm.functions.display_on_1s(2000) self.vm.functions.display_on_1s(3000) self.vm.functions.display_on_1s(4000) self.vm.functions.display("HH00000111112222233333") self.vm.functions.display_on_1s(5000) self.vm.functions.display_on_1s(6000) self.vm.functions.display_on_1s(7000) self.vm.functions.display_on_1s(8000) self.vm.functions.display_on_1s(9000) self.vm.mocks.assert_has_calls([ call.display('HH0000011111222223333344444555556666677777'), call.redraw_scroll(), call.display_on_1s(1000), call.cycle_batt_msg(), call.display_on_1s(2000), call.cycle_batt_msg(), call.display_on_1s(3000), call.redraw_8(), call.cycle_batt_msg(), call.display_on_1s(4000), call.cycle_batt_msg(), call.display('HH00000111112222233333'), call.redraw_8(), call.display_on_1s(5000), call.cycle_batt_msg(), call.display_on_1s(6000), call.cycle_batt_msg(), call.display_on_1s(7000), call.redraw_4(), call.cycle_batt_msg(), call.display_on_1s(8000), call.cycle_batt_msg(), call.display_on_1s(9000), call.cycle_batt_msg() ]) # Can change mode redraw_scroll.return_value = 0 self.vm.functions.display( "HH00000111112222233333444445555566666777778888899999") self.assertEqual(self.vm.globals.G_DISPLAY_MODE, 0)