def test_on_key(self): val = libretroControllers.getConfigValue( controllersConfig.Input("down", "key", "2", "1")) self.assertEquals("2", val) val = libretroControllers.getConfigValue( controllersConfig.Input("down", "key", "3", "8")) self.assertEquals("3", val)
def test_on_hat(self): val = libretroControllers.getConfigValue( controllersConfig.Input("down", "hat", "2", "1")) self.assertEquals("h2up", val) val = libretroControllers.getConfigValue( controllersConfig.Input("down", "hat", "3", "8")) self.assertEquals("h3left", val)
def test_on_axis(self): val = libretroControllers.getConfigValue( controllersConfig.Input("down", "axis", "10", "1")) self.assertEquals("+10", val) val = libretroControllers.getConfigValue( controllersConfig.Input("down", "axis", "10", "-1")) self.assertEquals("-10", val)
def setUp(self): self.snes = Emulator(name='snes', videomode='4', core='pocketsnes', shaders='', ratio='auto', smooth='2', rewind='false', emulator='libretro') self.snes2 = Emulator(name='snes', videomode='4', core='pocketsnes', shaders='', ratio='auto', smooth='2', rewind='false', emulator='libretro') self.nes = Emulator(name='nes', videomode='6', core='catsfc', shaders='', ratio='16/9', smooth='1', rewind='false', configfile='/myconfigfile.cfg', emulator='libretro') # test inputs self.basicInputs1 = {'hotkey': controllersConfig.Input("hotkey", "button", "10", "1")} self.basicController1 = controllersConfig.Controller("contr1", "joypad", "GUID1", 1, 0, "Joypad1RealName", self.basicInputs1) self.sdl2controler = controllersConfig.Controller("contr1", "joypad", "030000003512000012ab000010010000", 2, 1, "Bluetooth Wireless Controller ", self.basicInputs1) self.controllers = dict() self.controllers['1'] = self.basicController1 self.sdl2controllers = dict() self.sdl2controllers['1'] = self.basicController1 self.sdl2controllers['2'] = self.sdl2controler
# Injecting test recalbox.conf libretroControllers.settingsRoot = os.path.abspath( os.path.join(os.path.dirname(__file__), "tmp")) # Injecting test es_input controllersConfig.esInputs = os.path.abspath( os.path.join(os.path.dirname(__file__), "tmp/es_input.cfg")) # Injecting test retroarch.conf libretroSettingsFile = os.path.abspath( os.path.join(os.path.dirname(__file__), "tmp/retroarchcustom.cfg")) libretroSettings = unixSettings.UnixSettings(libretroSettingsFile) libretroControllers.libretroSettings = libretroSettings # Test objects basicInputs1 = {'a': controllersConfig.Input("a", "button", "10", "1")} basicController1 = controllersConfig.Controller("contr1", "joypad", "GUID1", "0", "Joypad1RealName", basicInputs1) basicController2 = controllersConfig.Controller("contr2", "joypad", "GUID2", "1", "Joypad2RealName", basicInputs1) basicController3 = controllersConfig.Controller("contr3", "joypad", "GUID3", "2", "Joypad3RealName", basicInputs1) basicController4 = controllersConfig.Controller("contr4", "joypad", "GUID4", "3", "Joypad4RealName", basicInputs1) controllers4 = { "1": basicController1, "2": basicController2,
sys.path.append( os.path.abspath(os.path.join(os.path.dirname(__file__), "../../.."))) import generators.libretro.libretroControllers as libretroControllers import controllersConfig as controllersConfig from Emulator import Emulator # Cloning config files shutil.copyfile(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../resources/retroarchcustom.cfg.origin")), \ os.path.abspath(os.path.join(os.path.dirname(__file__), "tmp/retroarchcustom.cfg"))) # Injecting test retroarchroot libretroControllers.settingsRoot = os.path.abspath( os.path.join(os.path.dirname(__file__), "tmp")) onlyBtnsInputs = {'up': controllersConfig.Input("up", "button", "1", "1")} onlyHatsInputs = {'up': controllersConfig.Input("up", "hat", "1", "1")} onlyAxisInputs = {'up': controllersConfig.Input("up", "axis", "1", "1")} axisAndBtnsInputs = { 'up': controllersConfig.Input("up", "button", "1", "1"), 'joystickup': controllersConfig.Input("up", "axis", "1", "1") } snes = Emulator('snes', 'snes', 'libretro') psx = Emulator('psx', 'psx', 'libretro') # Test the padtype settings class TestLibretroAnalogMode(unittest.TestCase): def test_padtype_only_btn(self): basicControllerBTN = controllersConfig.Controller(
videomode='4', shaders='', ratio='auto', smooth='2', emulator='pifba') fbaSystemCustom = Emulator(name='fba', videomode='6', shaders='', ratio='auto', smooth='2', emulator='pifba', configfile='lol') # test inputs basicInputs1 = { 'hotkey': controllersConfig.Input("hotkey", "button", "10", "1") } basicController1 = controllersConfig.Controller("contr1", "joypad", "GUID1", "0", "Joypad1RealName", basicInputs1) rom = "MyRom.zip" fba2xGen = Fba2xGenerator() fba2xGenerator.fba2xConfig.fbaSettings = fba2xConfig.fbaSettings class TestLibretroGenerator(unittest.TestCase): def test_generate_system_no_custom_settings(self): command = fba2xGen.generate(fbaSystem, rom, dict()) self.assertEquals(command.videomode, '4')
# Injecting test recalbox.conf libretroControllers.settingsRoot = os.path.abspath( os.path.join(os.path.dirname(__file__), "tmp")) # Injecting test es_input controllersConfig.esInputs = os.path.abspath( os.path.join(os.path.dirname(__file__), "tmp/es_input.cfg")) # Injecting test retroarch.conf libretroSettingsFile = os.path.abspath( os.path.join(os.path.dirname(__file__), "tmp/retroarchcustom.cfg")) libretroSettings = unixSettings.UnixSettings(libretroSettingsFile, ' ') libretroControllers.libretroSettings = libretroSettings # Test objects basicInputs1 = { 'a': controllersConfig.Input("a", "button", "10", "1"), 'start': controllersConfig.Input("start", "button", "11", "1") } basicController1 = controllersConfig.Controller("contr1", "joypad", "GUID1", '1', 0, "Joypad1RealName", basicInputs1) basicController2 = controllersConfig.Controller("contr2", "joypad", "GUID2", '2', 1, "Joypad2RealName", basicInputs1) basicController3 = controllersConfig.Controller("contr3", "joypad", "GUID3", '3', 2, "Joypad3RealName", basicInputs1) basicController4 = controllersConfig.Controller("contr4", "joypad", "GUID4", '4', 3, "Joypad4RealName", basicInputs1) controllers4 = {
def test_on_button(self): val = libretroControllers.getConfigValue(controllersConfig.Input("a", "button", "10", "1")) self.assertEquals("10", val)
import controllersConfig as controllersConfig fba2xCustom = os.path.abspath(os.path.join(os.path.dirname(__file__), 'tmp/fba2x.cfg')) # Cloning config files shutil.copyfile(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../resources/es_input.cfg.origin")), \ os.path.abspath(os.path.join(os.path.dirname(__file__), "tmp/es_input.cfg"))) shutil.copyfile(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../resources/fba2x.cfg.origin')), \ fba2xCustom) # Injecting test recalbox.conf controllersConfig.esInputs = os.path.abspath(os.path.join(os.path.dirname(__file__), "tmp/es_input.cfg")) # Test objects basicInputs1 = {'a': controllersConfig.Input("a", "button", "10", "1"),'hotkey': controllersConfig.Input("hotkey", "button", "10", "1")} basicController1 = controllersConfig.Controller("contr1", "joypad", "GUID1", "0", "Joypad1RealName", basicInputs1) PS3UUID = "060000004c0500006802000000010000" GPIOUUID = "15000000010000000100000000010000" fbaSettings = unixSettings.UnixSettings(fba2xCustom) class TestFba2xController(unittest.TestCase): def setUp(self): # Injecting test file fba2xControllers.fbaSettings = fbaSettings def test_generate_simple_controller(self): config = fba2xControllers.generateControllerConfig(basicController1) self.assertEquals(config['Y'], '"10"')