예제 #1
0
    def test_certain_modifier_key_presses_do_not_change_state(self):
        app = MockApp()
        state = dispatcher.init_state(dispatcher.default_state, app, None)
        state.send(NormalEvent(ON_KEY_PRESS, pkey.M))
        current_state = state.gi_frame.f_locals['current_state']
        self.assertEqual(current_state.__name__, 'marking')

        keys = [
            pkey.LSHIFT, pkey.RSHIFT,
            pkey.LCTRL, pkey.RCTRL,
            pkey.CAPSLOCK,
            pkey.LMETA, pkey.RMETA,
            pkey.LALT, pkey.RALT,
            pkey.LWINDOWS, pkey.RWINDOWS,
            pkey.LCOMMAND, pkey.RCOMMAND,
            pkey.LOPTION, pkey.ROPTION
        ]

        for key in keys:
            state.send(NormalEvent(ON_KEY_PRESS, key))
            current_state = state.gi_frame.f_locals['current_state']
            self.assertIsNotNone(current_state,
                    msg="{} has changed the state".format(pkey.symbol_string(key)))
            self.assertEqual(current_state.__name__, 'marking',
                    msg="current_state was changed by {}".format(pkey.symbol_string(key)))
예제 #2
0
    def test_multipliers(self):
        app = MockApp()

        state = dispatcher.init_state(dispatcher.default_state, app, None)
        state.send(NormalEvent(ON_KEY_PRESS, pkey._1))
        state.send(NormalEvent(ON_KEY_PRESS, pkey._0))
        state.send(NormalEvent(ON_KEY_PRESS, pkey.H))
        assert_array_equal(app.cursor.position, vec2i(-10, 0))
예제 #3
0
    def test_set_mark(self):
        app = MockApp();
        app.cursor.position = vec2i(314, 159);

        state = dispatcher.init_state(dispatcher.default_state, app, None);
        state.send(NormalEvent(ON_KEY_PRESS, pkey.M));
        state.send(NormalEvent(ON_KEY_RELEASE, pkey.M));
        state.send(NormalEvent(ON_KEY_PRESS, pkey.B));

        app.cursor.position = vec2i(0, 0);
        assert_array_equal(app.marks['b'], vec2i(314, 159))
예제 #4
0
    def test_fast_move_doesnt_keep_moving_after_key_release(self):
        app = MockApp()
        app.time = 0

        state = dispatcher.init_state(dispatcher.default_state, app, None)
        state.send(NormalEvent(ON_KEY_PRESS, pkey.H))
        assert_array_equal(app.cursor.position, vec2i(-1, 0))

        state.send(NormalEvent(ON_KEY_RELEASE, pkey.H))

        app.time = 0.71
        state.send(NormalEvent(TIMER_FIRE));
        assert_array_equal(app.cursor.position, vec2i(-1, 0))
예제 #5
0
    def test_multipliers_fast_move_starts_at_jump(self):
        app = MockApp()
        app.time = 0

        state = dispatcher.init_state(dispatcher.default_state, app, None)
        state.send(NormalEvent(ON_KEY_PRESS, pkey._2))
        state.send(NormalEvent(ON_KEY_PRESS, pkey.H))
        assert_array_equal(app.cursor.position, vec2i(-2, 0))

        app.time = 0.51
        state.send(NormalEvent(TIMER_FIRE))
        assert_array_equal(app.cursor.position, vec2i(-3, 0))

        app.time = 0.61
        state.send(NormalEvent(TIMER_FIRE))
        assert_array_equal(app.cursor.position, vec2i(-4, 0))
예제 #6
0
    def test_fast_move(self):
        app = MockApp()
        app.time = 0

        state = dispatcher.init_state(dispatcher.default_state, app, None)
        state.send(NormalEvent(ON_KEY_PRESS, pkey.H))
        assert_array_equal(app.cursor.position, vec2i(-1, 0))

        app.time = 0.498
        state.send(NormalEvent(TIMER_FIRE));
        assert_array_equal(app.cursor.position, vec2i(-1, 0))

        app.time = 0.51
        state.send(NormalEvent(TIMER_FIRE));
        assert_array_equal(app.cursor.position, vec2i(-2, 0))

        app.time = 0.71
        state.send(NormalEvent(TIMER_FIRE));
        assert_array_equal(app.cursor.position, vec2i(-6, 0))

        app.time = 0.81
        state.send(NormalEvent(TIMER_FIRE));
        assert_array_equal(app.cursor.position, vec2i(-11, 0))
예제 #7
0
    def test_move_command(self):
        app = MockApp()

        state = dispatcher.init_state(dispatcher.default_state, app, None);
        state.send(NormalEvent(ON_KEY_PRESS, pkey.H))
        assert_array_equal(app.cursor.position, vec2i(-1, 0))
예제 #8
0
 def test_switch_to_ex_mode__semi_colon_and_shift(self):
     app = MockApp()
     state = dispatcher.init_state(dispatcher.default_state, app, None)
     state.send(NormalEvent(ON_KEY_PRESS, pkey.SEMICOLON, pkey.MOD_SHIFT))
     self.assertEqual(app.down_action, app.switch_to_ex_mode)
     self.assertTrue(app.dispatch_both_was_called)
예제 #9
0
 def test_switch_to_ex_mode(self):
     app = MockApp()
     state = dispatcher.init_state(dispatcher.default_state, app, None)
     state.send(NormalEvent(ON_KEY_PRESS, pkey.COLON))
     self.assertEqual(app.down_action, app.switch_to_ex_mode)
     self.assertTrue(app.dispatch_both_was_called)
예제 #10
0
 def test_scale_down(self):
     app = MockApp();
     state = dispatcher.init_state(dispatcher.default_state, app, None);
     state.send(NormalEvent(ON_KEY_PRESS, pkey.S, pkey.MOD_SHIFT))
     self.assertEqual(app.grid.scale, 2)
예제 #11
0
    def test_toggle_on(self):
        app = MockApp();

        state = dispatcher.init_state(dispatcher.default_state, app, None);
        state.send(NormalEvent(ON_KEY_PRESS, pkey.G))
        self.assertTrue(app.grid.visible)