Ejemplo n.º 1
0
 def test_move_one_from_start_to_center(self):
     before = parse_tab_lines([
         'f.0.0\ta\turl',
         'f.0.1\ta\turl',
         'f.0.2\ta\turl',
         'f.0.3\ta\turl',
         'f.0.4\ta\turl',
         'f.0.5\ta\turl',
         'f.0.6\ta\turl',
         'f.0.7\ta\turl',
         'f.0.8\ta\turl',
     ])
     after = parse_tab_lines([
         'f.0.1\ta\turl',
         'f.0.2\ta\turl',
         'f.0.3\ta\turl',
         'f.0.4\ta\turl',
         'f.0.0\ta\turl',
         'f.0.5\ta\turl',
         'f.0.6\ta\turl',
         'f.0.7\ta\turl',
         'f.0.8\ta\turl',
     ])
     commands = infer_move_commands(before, after)
     self.assertEqual(commands, [(0, 0, 4)])
     actual_after = apply_move_commands(before, commands)
     self.assertEqual(actual_after, after)
Ejemplo n.º 2
0
 def test_crossings(self):
     before = parse_tab_lines([
         'f.0.0\ta\turl',
         'f.0.1\ta\turl',
         'f.0.2\ta\turl',
         'f.0.3\ta\turl',
         'f.0.4\ta\turl',
         'f.0.5\ta\turl',
         'f.0.6\ta\turl',
         'f.0.7\ta\turl',
         'f.0.8\ta\turl',
     ])
     after = parse_tab_lines([
         'f.0.4\ta\turl',
         'f.0.0\ta\turl',
         'f.0.1\ta\turl',
         'f.0.2\ta\turl',
         'f.0.3\ta\turl',
         'f.0.6\ta\turl',
         'f.0.7\ta\turl',
         'f.0.8\ta\turl',
         'f.0.5\ta\turl',
     ])
     commands = infer_move_commands(before, after)
     self.assertEqual(commands, [(4, 0, 0), (5, 0, 8)])
     actual_after = apply_move_commands(before, commands)
     self.assertEqual(actual_after, after)
Ejemplo n.º 3
0
    def _move_tabs_if_changed(self, api, tabs_before, tabs_after):
        delete_commands, move_commands = infer_delete_and_move_commands(
            parse_tab_lines(tabs_before), parse_tab_lines(tabs_after))

        if delete_commands:
            print('DELETE', delete_commands)
            api.close_tabs(delete_commands)

        if move_commands:
            print('MOVE', move_commands)
            api.move_tabs(move_commands)
Ejemplo n.º 4
0
 def test_move_one_to_another_existing_window_same_index(self):
     before = parse_tab_lines([
         'f.0.0\ta\turl',
         'f.1.1\ta\turl',
     ])
     after = parse_tab_lines([
         'f.1.0\ta\turl',
         'f.1.1\ta\turl',
     ])
     delete_commands, move_commands = infer_delete_and_move_commands(before, after)
     self.assertGreater(len(move_commands), 0)
     actual_after = apply_move_commands(before, move_commands)
     self.assertEqual(actual_after, after)
Ejemplo n.º 5
0
 def test_move_one_to_another_existing_window_above_2(self):
     before = parse_tab_lines([
         'f.0.0\ta1\turl1',
         'f.0.1\ta2\turl2',
         'f.1.2\ta3\turl3',
         'f.1.3\ta4\turl4',
     ])
     after = parse_tab_lines([
         'f.0.0\ta1\turl1',
         'f.0.1\ta2\turl2',
         'f.0.3\ta4\turl4',
         'f.1.2\ta3\turl3',
     ])
     delete_commands, move_commands = infer_delete_and_move_commands(before, after)
     self.assertGreater(len(move_commands), 0)
     actual_after = apply_move_commands(before, move_commands)
     self.assertEqual(actual_after, after)
Ejemplo n.º 6
0
 def test_decreasing_ids_from_start_to_end(self):
     before = parse_tab_lines([
         'f.0.10\ta\turl',
         'f.0.9\ta\turl',
         'f.0.8\ta\turl',
         'f.0.7\ta\turl',
     ])
     after = parse_tab_lines([
         'f.0.9\ta\turl',
         'f.0.8\ta\turl',
         'f.0.7\ta\turl',
         'f.0.10\ta\turl',
     ])
     commands = infer_move_commands(before, after)
     self.assertEqual(commands, [(10, 0, 3)])
     actual_after = apply_move_commands(before, commands)
     self.assertEqual(actual_after, after)
Ejemplo n.º 7
0
    def _move_tabs_if_changed(self, api, tabs_before, tabs_after):
        # if tabs_after is None:
        # return

        # from pprint import pprint
        # print('_move_tabs_if_changed tabs_before')
        # pprint(tabs_before)
        # print('_move_tabs_if_changed tabs_after')
        # pprint(tabs_after)

        delete_commands, move_commands = infer_delete_and_move_commands(
            parse_tab_lines(tabs_before), parse_tab_lines(tabs_after))

        if delete_commands:
            api.close_tabs(delete_commands)
            # raise RuntimeError('DELETE COMMANDS ARE NOT SUPPORTED YET')

        api.move_tabs(move_commands)
Ejemplo n.º 8
0
 def test_move_pair_from_end_to_start(self):
     before = parse_tab_lines([
         'f.0.0\ta\turl',
         'f.0.1\ta\turl',
         'f.0.2\ta\turl',
         'f.0.3\ta\turl',
         'f.0.4\ta\turl',
     ])
     after = parse_tab_lines([
         'f.0.3\ta\turl',
         'f.0.4\ta\turl',
         'f.0.0\ta\turl',
         'f.0.1\ta\turl',
         'f.0.2\ta\turl',
     ])
     commands = infer_move_commands(before, after)
     # self.assertEqual(commands, [(1, 0, 4), (0, 0, 3)])
     actual_after = apply_move_commands(before, commands)
     self.assertEqual(actual_after, after)
Ejemplo n.º 9
0
 def test_move_several_downwards(self):
     before = parse_tab_lines([
         'f.0.0\ta\turl',
         'f.0.1\ta\turl',
         'f.0.2\ta\turl',
         'f.0.3\ta\turl',
         'f.0.4\ta\turl',
         'f.0.5\ta\turl',
         'f.0.6\ta\turl',
     ])
     after = parse_tab_lines([
         'f.0.2\ta\turl',
         'f.0.4\ta\turl',
         'f.0.6\ta\turl',
         'f.0.0\ta\turl',
         'f.0.1\ta\turl',
         'f.0.3\ta\turl',
         'f.0.5\ta\turl',
     ])
     commands = infer_move_commands(before, after)
     actual_after = apply_move_commands(before, commands)
     self.assertEqual(actual_after, after)
Ejemplo n.º 10
0
 def _eq(self, tabs_before, tabs_after, expected_deletes, expected_moves):
     deletes, moves = infer_delete_and_move_commands(
         parse_tab_lines(tabs_before),
         parse_tab_lines( tabs_after))
     self.assertEqual(expected_deletes, deletes)
     self.assertEqual(expected_moves, moves)
Ejemplo n.º 11
0
 def tabs():
     return parse_tab_lines(BtCommandWrapper.list())