def test_joystick_index(self): if self.jcount == 0: self.skipTest("no joysticks detected") for index in range(self.jcount): stick = joystick.joystick_open(index) self.assertIsInstance(stick, joystick.SDL_Joystick) self.assertEqual(joystick.joystick_index(stick), index) joystick.joystick_close(stick) pass
def test_joystick_num_hats(self): if self.jcount == 0: self.skipTest("no joysticks detected") for index in range(self.jcount): stick = joystick.joystick_open(index) self.assertIsInstance(stick, joystick.SDL_Joystick) hats = joystick.joystick_num_hats(stick) self.assertGreaterEqual(hats, 0) joystick.joystick_close(stick)
def test_joystick_get_axis(self): if self.jcount == 0: self.skipTest("no joysticks detected") for index in range(self.jcount): stick = joystick.joystick_open(index) for axis in range(joystick.joystick_num_axes(stick)): val = joystick.joystick_get_axis(stick, axis) self.assertTrue(-32768 <= val <= 32767) joystick.joystick_close(stick)
def test_joystick_get_button(self): if self.jcount == 0: self.skipTest("no joysticks detected") for index in range(self.jcount): stick = joystick.joystick_open(index) for button in range(joystick.joystick_num_buttons(stick)): val = joystick.joystick_get_button(stick, button) self.assertIsInstance(val, bool) joystick.joystick_close(stick) pass
def test_joystick_get_hat(self): if self.jcount == 0: self.skipTest("no joysticks detected") for index in range(self.jcount): stick = joystick.joystick_open(index) for hat in range(joystick.joystick_num_hats(stick)): val = joystick.joystick_get_hat(stick, hat) self.assertIsInstance(val, int) # TODO joystick.joystick_close(stick)
def test_joystick_get_ball(self): if self.jcount == 0: self.skipTest("no joysticks detected") for index in range(self.jcount): stick = joystick.joystick_open(index) for ball in range(joystick.joystick_num_balls(stick)): dx, dy = joystick.joystick_get_ball(stick, ball) self.assertIsInstance(dx, int) self.assertIsInstance(dy, int) # TODO joystick.joystick_close(stick)
def test_joystick_open_opened_close(self): if self.jcount == 0: self.skipTest("no joysticks detected") for index in range(self.jcount): stick = joystick.joystick_open(index) self.assertIsInstance(stick, joystick.SDL_Joystick) self.assertTrue(joystick.joystick_opened(index)) joystick.joystick_close(stick) self.assertFalse(joystick.joystick_opened(index)) self.assertRaises(sdl.SDLError, joystick.joystick_open, self.jcount + 1) self.assertRaises(sdl.SDLError, joystick.joystick_open, -10) self.assertRaises(ValueError, joystick.joystick_open, "Test") self.assertRaises(TypeError, joystick.joystick_open, None)