def test_replacePlaceholdersInParams(self): conf = self._get_config() gameRow = GameView(self.gdb).getObjectById(1) filenameRows = File(self.gdb).getRomsByGameId( gameRow[DataBaseObject.COL_ID]) rom = filenameRows[0][0] abs_launcher = AbstractLauncher(self.gdb, conf, RCBMockGui()) emulatorParams = '-v -L /Applications/RetroArch.app/Contents/Resources/cores/bnes_libretro.dylib "%rom%"' emuparams = abs_launcher.replacePlaceholdersInParams( emulatorParams, rom, gameRow) self.assertEqual( '-v -L /Applications/RetroArch.app/Contents/Resources/cores/bnes_libretro.dylib "./testdata/roms/SNES\Chrono Trigger\game.sfc"', emuparams) emulatorParams = '%ROM%' emuparams = abs_launcher.replacePlaceholdersInParams( emulatorParams, rom, gameRow) self.assertEqual('./testdata/roms/SNES\Chrono Trigger\game.sfc', emuparams) emulatorParams = '%Rom%' emuparams = abs_launcher.replacePlaceholdersInParams( emulatorParams, rom, gameRow) self.assertEqual('./testdata/roms/SNES\Chrono Trigger\game.sfc', emuparams) emulatorParams = '%romfile%' emuparams = abs_launcher.replacePlaceholdersInParams( emulatorParams, rom, gameRow) self.assertEqual('game.sfc', emuparams) emulatorParams = '%romname%' emuparams = abs_launcher.replacePlaceholdersInParams( emulatorParams, rom, gameRow) self.assertEqual('game', emuparams) emulatorParams = '%game%' emuparams = abs_launcher.replacePlaceholdersInParams( emulatorParams, rom, gameRow) self.assertEqual('Chrono Trigger', emuparams) emulatorParams = '%asknum%' from xbmcgui import Dialog Dialog.select_result = 0 emuparams = abs_launcher.replacePlaceholdersInParams( emulatorParams, rom, gameRow) self.assertEqual('0', emuparams) emulatorParams = '%asktext%' emuparams = abs_launcher.replacePlaceholdersInParams( emulatorParams, rom, gameRow) #xbmcgui.Dialog.input() returns "Text" self.assertEqual('Text', emuparams)
def test_get_launcher_by_gameid(self): conf = self._get_config() abs_launcher = AbstractLauncher(self.gdb, conf, RCBMockGui()) # 10 = 1080 Snowboarding, N64 launcher = abs_launcher.get_launcher_by_gameid(10) self.assertTrue(isinstance(launcher, RetroPlayer_Launcher)) # 3 = Airborn Ranger, Amiga launcher = abs_launcher.get_launcher_by_gameid(3) self.assertTrue(isinstance(launcher, Cmd_Launcher))
def test_checkGameHasSaveStates(self): conf = self._get_config() # 1 = Chrono Trigger, SNES gameRow = GameView(self.gdb).getObjectById(1) romCollection = conf.romCollections[str( gameRow[GameView.COL_romCollectionId])] filenameRows = File(self.gdb).getRomsByGameId( gameRow[DataBaseObject.COL_ID]) from xbmcgui import Dialog Dialog.select_result = 1 abs_launcher = AbstractLauncher(self.gdb, conf, RCBMockGui()) savestateparams = abs_launcher.checkGameHasSaveStates( romCollection, gameRow, filenameRows) self.assertEqual("./testdata/savestates/SNES/Chrono Trigger.state", savestateparams)
def test_make_local_copy(self): conf = self._get_config() # Silent Hill, PSX gameRow = GameView(self.gdb).getObjectById(12) filenameRows = File(self.gdb).getRomsByGameId( gameRow[DataBaseObject.COL_ID]) romCollection = conf.romCollections[str( gameRow[GameView.COL_romCollectionId])] rom = filenameRows[0][0] abs_launcher = AbstractLauncher(self.gdb, conf, RCBMockGui()) rom = abs_launcher._copylocal(romCollection, rom) expected_rom = os.path.join(os.getcwd(), 'script.games.rom.collection.browser', 'tmp', 'Playstation', 'Silent Hill (Disc 1 of 2).bin') self.assertEqual(expected_rom, rom)
def launchEmu(self): log.info("Begin launchEmu UIGameInfoView") AbstractLauncher(self.gdb, self.config, self).launch_game(self.selectedGameId, self.selectedGame) self.saveViewState(False) self.close() log.info("End launchEmu UIGameInfoView")
def test_selectdisc(self): conf = self._get_config() #Formula One, Amiga gameRow = GameView(self.gdb).getObjectById(6) filenameRows = File(self.gdb).getRomsByGameId( gameRow[DataBaseObject.COL_ID]) romCollection = conf.romCollections[str( gameRow[GameView.COL_romCollectionId])] abs_launcher = AbstractLauncher(self.gdb, conf, RCBMockGui()) discname = abs_launcher._selectdisc(romCollection, filenameRows, False) # EmuParams contains %I%, so we expect no disc selection self.assertEqual('', discname) # Silent Hill, PSX gameRow = GameView(self.gdb).getObjectById(12) filenameRows = File(self.gdb).getRomsByGameId( gameRow[DataBaseObject.COL_ID]) romCollection = conf.romCollections[str( gameRow[GameView.COL_romCollectionId])] abs_launcher = AbstractLauncher(self.gdb, conf, RCBMockGui()) discname = abs_launcher._selectdisc(romCollection, filenameRows, False) self.assertEqual('(Disc 1 of 2)', discname)
def launchGame(self, param): import util from base_launcher import AbstractLauncher from gamedatabase import GameDataBase from config import Config gdb = GameDataBase(util.getAddonDataPath()) gdb.connect() #HACK if invoked from widget addon there is an additional ? in param param = param.replace('?', '') gameId = int(param.replace('launchid=', '')) config = Config(None) config.readXml() gui = dummyGUI() #RCBLauncher().launchEmu(gdb, gui, gameId, config, None) AbstractLauncher(gdb, config, gui).launch_game(gameId, None)
def test_launch_game(self): conf = self._get_config() gameid = 10 AbstractLauncher(self.gdb, conf, RCBMockGui()).launch_game(gameid, None)