Esempio n. 1
0
    def test_pygame2_sdl_keyboard_get_repeat(self):

        # __doc__ (as of 2009-05-13) for pygame2.sdl.keyboard.get_repeat:

        # get_repeat () -> delay, interval
        # 
        # Gets the currently set keyboard repeat delay and interval.
        keyboard.enable_repeat (0, 0)
        self.assertEqual (keyboard.get_repeat (), (0, 0))
        keyboard.enable_repeat (10, 10)
        self.assertEqual (keyboard.get_repeat (), (10, 10))
        keyboard.enable_repeat (5, 2)
        self.assertEqual (keyboard.get_repeat (), (5, 2))
        keyboard.enable_repeat (0, 5)
        self.assertEqual (keyboard.get_repeat (), (0, 5))
        keyboard.enable_repeat (7, 0)
        self.assertEqual (keyboard.get_repeat (), (7, 0))
Esempio n. 2
0
    def test_pygame2_sdl_keyboard_enable_repeat(self):

        # __doc__ (as of 2009-05-13) for pygame2.sdl.keyboard.enable_repeat:

        # enable_repeat (delay, interval) -> None
        # 
        # Enables or disables the keyboard repeat rate.
        # 
        # delay specifies how long a key must be pressed before the
        # repeat begins. interval is the speed with which it
        # repeats. delay and interval are expressed as
        # milliseconds. Thus, after the initial delay has passed,
        # repeated KEYDOWN events are sent through the event queue,
        # using the specified interval.  Setting delay to 0 will disable
        # repeating completely.
        # 
        # Setting delay to 0 will disable repeating completely.
        self.assertTrue (keyboard.enable_repeat (0, 0) == None)
        self.assertTrue (keyboard.enable_repeat (1, 1) == None)
        self.assertTrue (keyboard.enable_repeat (900, 1000) == None)
        self.assertRaises (ValueError, keyboard.enable_repeat, -1, -1)
        self.assertRaises (ValueError, keyboard.enable_repeat,  1, -1)
        self.assertRaises (ValueError, keyboard.enable_repeat, -1,  1)