def test_buildcmd_placeholders(self): rcb_launcher = RCBLauncher() config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata', 'config', 'romcollections_launchertests.xml') conf = Config(config_xml_file) conf.readXml() #%ROM% gameid = 7 game = GameView(self.gdb).getObjectById(gameid) filename_rows = File(self.gdb).getRomsByGameId(game[File.COL_ID]) rcb_launcher.romCollection = conf.romCollections[str( game[GameView.COL_romCollectionId])] cmd, precmd, postcmd, roms = rcb_launcher._buildCmd( RCBMockGui(), filename_rows, game, False) self.assertEquals( cmd, '"/Path/To/Atari2600/Emulator" "./testdata/roms/Atari 2600\\Adventure (1980) (Atari).a26"' ) # %ROMFILE% gameid = 11 game = GameView(self.gdb).getObjectById(gameid) filename_rows = File(self.gdb).getRomsByGameId(game[File.COL_ID]) rcb_launcher.romCollection = conf.romCollections[str( game[GameView.COL_romCollectionId])] cmd, precmd, postcmd, roms = rcb_launcher._buildCmd( RCBMockGui(), filename_rows, game, False) self.assertEquals(cmd, '"/Path/To/PSX/Emulator" "Bushido Blade.img"')
def test_cache_artwork_1_rom_collection_n_artworktypes_add_artwork(self): # Load a config file with 2 valid RomCollections and all FileTypes and ImagePlacings config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata', 'config', 'romcollections_imageloading.xml') conf = Config(config_xml_file) conf.readXml() # image should be missing at start game = GameView(self.gdb).getGameById(5) self.assertIsNone( game[GameView.COL_fileType1], "fileType1 expected to be missing before update artwork cache") self.assertIsNone( game[GameView.COL_fileType4], "fileType1 expected to be missing before update artwork cache") rcid = 1 artwork_type = 0 ArtworkUpdater(RCBMockGui(), self.gdb, conf).update_artwork_cache(rcid, artwork_type) # image should be available now game = GameView(self.gdb).getGameById(5) self.assertEquals("./testdata/artwork/Amiga/boxfront/Eliminator.png", game[GameView.COL_fileType1]) self.assertEquals("./testdata/artwork/Amiga/screenshot/Eliminator.png", game[GameView.COL_fileType4])
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 getRecentlyAddedRoms(self, gdb, limit, platform=None): xbmc.log('RCB widget: getRecentlyAddedRoms') if not platform: query = 'SELECT * FROM GameView ORDER BY ID DESC LIMIT %s;' % limit games = GameView(gdb).getGamesByQueryNoArgs(query) else: query = 'SELECT * FROM GameView WHERE romCollectionId = ? ORDER BY ID DESC LIMIT %s;' % limit games = GameView(gdb).getGamesByQuery(query, (platform, )) xbmc.log('RCB widget: recently added games: %s' % games) self.addGamesToDirectory(gdb, games, limit, platform)
def getFavoriteRoms(self, gdb, limit, platform=None): xbmc.log('RCB widget: getFavoriteRoms') if not platform: query = 'SELECT * FROM GameView WHERE isFavorite = 1 LIMIT %s;' % limit games = GameView(gdb).getGamesByQueryNoArgs(query) else: query = 'SELECT * FROM GameView WHERE isFavorite = 1 AND romCollectionId = ? LIMIT %s;' % limit games = GameView(gdb).getGamesByQuery(query, (platform, )) xbmc.log('RCB widget: favorite games: %s' % games) self.addGamesToDirectory(gdb, games, limit, platform)
def getMostPlayedRoms(self, gdb, limit, platform=None): xbmc.log('RCB widget: getMostPlayedRoms') if not platform: query = 'Select * From GameView Where launchCount > 0 Order by launchCount desc Limit %s;' % limit games = GameView(gdb).getGamesByQueryNoArgs(query) else: query = 'Select * From GameView Where launchCount > 0 AND romCollectionId = ? Order by launchCount desc Limit %s;' % limit games = GameView(gdb).getGamesByQuery(query, (platform, )) xbmc.log('RCB widget: most played games: %s' % games) self.addGamesToDirectory(gdb, games, limit, platform)
def test_RetrieveGameWithUnicode(self): ''' Validate items with unicode descriptions are stored/retrieved correctly ''' game = GameView(self.gdb).getGameById(66) self.assertTrue( game[GameView.COL_description].startswith(u'Mario\u2019s off'), 'Game with unicode plot not handled correctly')
def test_RetrieveGameByIdMultipleGenres(self): game = GameView(self.gdb).getGameById(50) self.assertTrue( game[GameView.COL_NAME] == 'Legend of Zelda, The - A Link to the Past (USA)', 'Game with ID 50 expected to be Legend of Zelda, The - A Link to the Past (USA) but was %s' % game[GameView.COL_NAME]) self.assertTrue( game[GameView.COL_publisher] == 'Nintendo', 'Publisher of game with ID 50 expected to be Nintendo EAD but was %s' % game[GameView.COL_publisher]) self.assertTrue( game[GameView.COL_developer] == 'Nintendo EAD', 'Developer of game with ID 50 expected to be Nintendo but was %s' % game[GameView.COL_developer]) self.assertTrue( game[GameView.COL_year] == '1992', 'Year of game with ID 50 expected to be 1992 but was %s' % game[GameView.COL_year]) self.assertTrue( game[GameView.COL_genre] == 'Action, Adventure, Role-Playing', 'Genre of game with ID 50 expected to be Action, Adventure, Role-Playing but was %s' % game[GameView.COL_genre])
def test_buildCmd_multidisc_psx(self): rcb_launcher = RCBLauncher() config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata', 'config', 'romcollections_imageloading.xml') conf = Config(config_xml_file) conf.readXml() gameid = 12 game = GameView(self.gdb).getObjectById(gameid) filename_rows = File(self.gdb).getRomsByGameId(game[File.COL_ID]) rcb_launcher.romCollection = conf.romCollections[str( game[GameView.COL_romCollectionId])] from xbmcgui import Dialog #select disk 1 Dialog.select_result = 0 cmd, precmd, postcmd, roms = rcb_launcher._buildCmd( RCBMockGui(), filename_rows, game, False) self.assertEquals( cmd, '"/Path/To/PSX/Emulator" "./testdata/roms/PSX\\Silent Hill (Disc 1 of 2).bin"' ) #select disk 2 Dialog.select_result = 1 cmd, precmd, postcmd, roms = rcb_launcher._buildCmd( RCBMockGui(), filename_rows, game, False) self.assertEquals( cmd, '"/Path/To/PSX/Emulator" "./testdata/roms/PSX\\Silent Hill (Disc 2 of 2).bin"' )
def test_import_initial_offline_gdbi(self): config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata', 'config', 'romcollections_importtests.xml') conf = Config(config_xml_file) conf.readXml() rcs = {} rcs[2] = conf.romCollections['2'] #adjust settings xbmcaddon._settings['rcb_nfoFolder'] = '' xbmcaddon._settings['rcb_PreferNfoFileIfAvailable'] = 'false' xbmcaddon._settings['rcb_ignoreGamesWithoutDesc'] = 'false' xbmcaddon._settings['rcb_scrapingMode'] = 'Automatic: Accurate' dbu = DBUpdate() dbu.updateDB(self.gdb, RCBMockGui(), rcs, False) likeStmnt = '0 = 0' games = GameView(self.gdb).getFilteredGames(2, 0, 0, 0, 0, 0, 0, 0, 0, likeStmnt, '', 0) self.assertEquals(len(games), 4) adventure = games[0] self.assertEquals(adventure[GameView.COL_NAME], 'Adventure') self.assertEquals(adventure[GameView.COL_year], '1980') self.assertEquals(adventure[GameView.COL_publisher], 'Atari, Inc.') self.assertEquals(adventure[GameView.COL_developer], 'Atari, Inc.') self.assertEquals(adventure[GameView.COL_genre], 'Adventure') self.assertEquals(adventure[GameView.COL_rating], '3.8') self.assertEquals(adventure[GameView.COL_maxPlayers], '1 Player') self.assertTrue(adventure[GameView.COL_description].startswith( 'A graphic dungeon quest inspired by the old mainframe game of the same name' )) airSeaBattle = games[1] self.assertEquals(airSeaBattle[GameView.COL_NAME], 'Air-Sea Battle') self.assertEquals(airSeaBattle[GameView.COL_year], '1977') self.assertEquals(airSeaBattle[GameView.COL_publisher], 'Sears, Roebuck and Co.') self.assertEquals(airSeaBattle[GameView.COL_developer], 'Atari, Inc.') self.assertEquals(airSeaBattle[GameView.COL_genre], 'Shooter') self.assertEquals(airSeaBattle[GameView.COL_rating], '2.4') self.assertEquals(airSeaBattle[GameView.COL_maxPlayers], '1-2 Players') self.assertTrue(airSeaBattle[GameView.COL_description].startswith( 'Air-Sea Battle is basically a target shooting game.')) asteroids = games[2] self.assertEquals(asteroids[GameView.COL_NAME], 'Asteroids') self.assertEquals(asteroids[GameView.COL_year], '1981') self.assertEquals(asteroids[GameView.COL_publisher], 'Atari, Inc.') self.assertEquals(asteroids[GameView.COL_developer], 'Atari, Inc.') self.assertEquals(asteroids[GameView.COL_genre], 'Shooter') self.assertEquals(asteroids[GameView.COL_rating], '3.5') self.assertEquals(asteroids[GameView.COL_maxPlayers], '1-2 Players') self.assertTrue(asteroids[GameView.COL_description].startswith( 'Asteroids is a conversion of the arcade game of the same name.'))
def test_replace_gamecmd(self): # 9 = Asteroids, Atari 2600 gameRow = GameView(self.gdb).getObjectById(9) emuParams = '%ROM% %GAMECMD%' emuParams = Cmd_Launcher().replace_gamecmd(gameRow, emuParams) self.assertEqual('%ROM% My Game Cmd', emuParams)
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 getRandomPlatformId(self, gdb): xbmc.log('RCB widget: getRandomPlatformId') #HACK: as we have no Platform table we get a random platform from table Game query = 'Select Distinct romCollectionId From Game Order by RANDOM() LIMIT 1' gameRow = GameView(gdb).getObjectByQuery(query, []) platformId = gameRow[0] xbmc.log('RCB widget: random platform: %s' % platformId) return platformId
def test_RetrieveMultipleGamesByYear(self): ''' Validate retrieve by year works ''' newgames = GameView(self.gdb).getFilteredGames(0, 0, 9, 0, 0, 0, 0, 0, 0, '0 = 0', '', 0) #self.assertIsInstance(newgames[0], gameobj, u'Expected type of return objects to be {0}, was {1}'.format(gameobj, type(newgames[0]))) self.assertTrue( len(newgames) == 5, u'Expected 5 games found for year = 9 (1992), found {0}'.format( len(newgames)))
def test_import_multirompath_multidisc(self): config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata', 'config', 'romcollections_importtests.xml') conf = Config(config_xml_file) conf.readXml() rcs = {} rcs[4] = conf.romCollections['4'] self.register_responses_PSX() # adjust settings xbmcaddon._settings[ 'rcb_nfoFolder'] = './script.games.rom.collection.browser/nfo/' xbmcaddon._settings['rcb_PreferNfoFileIfAvailable'] = 'false' xbmcaddon._settings['rcb_ignoreGamesWithoutDesc'] = 'true' xbmcaddon._settings['rcb_scrapingMode'] = 'Automatic: Accurate' dbu = DBUpdate() dbu.updateDB(self.gdb, RCBMockGui(), rcs, False) likeStmnt = '0 = 0' games = GameView(self.gdb).getFilteredGames(4, 0, 0, 0, 0, 0, 0, 0, 0, likeStmnt, '', 0) self.assertEquals(len(games), 2) bushido = games[0] self.assertEquals(bushido[GameView.COL_NAME], 'Bushido Blade') self.assertEquals(bushido[GameView.COL_year], '1997') self.assertTrue(bushido[GameView.COL_description].startswith( '"Bushido" is the soul of Japan - an ancient honor code deeply followed by samurai warriors for centuries' )) self.assertEquals(bushido[GameView.COL_genre], 'Fighting') self.assertEquals(bushido[GameView.COL_maxPlayers], '2') self.assertEquals(bushido[GameView.COL_publisher], 'Square, SCEA') self.assertEquals(bushido[GameView.COL_developer], 'Light Weight') roms = File(self.gdb).getRomsByGameId(bushido[GameView.COL_ID]) self.assertEquals(len(roms), 1) silenthill = games[1] self.assertEquals(silenthill[GameView.COL_NAME], 'Silent Hill') self.assertEquals(silenthill[GameView.COL_year], '1999') self.assertTrue(silenthill[GameView.COL_description].startswith( 'Silent Hill is a 1999 survival horror video game for the PlayStation.' )) self.assertEquals(silenthill[GameView.COL_genre], 'Action, Horror') self.assertEquals(silenthill[GameView.COL_maxPlayers], '1') self.assertEquals(silenthill[GameView.COL_publisher], 'Konami Digital Entertainment') self.assertEquals(silenthill[GameView.COL_developer], 'Team Silent, Konami') roms = File(self.gdb).getRomsByGameId(silenthill[GameView.COL_ID]) self.assertEquals(len(roms), 2)
def _update_artwork_cache_for_romcollection(self, rom_collection, file_type_id, media_dict): log.info('Begin _update_artwork_cache_for_romcollection') log.info('Update artwork cache for Rom Collection %s' % str(rom_collection.id)) continue_update = True media_paths_dict = {} try: media_paths_dict = media_dict[rom_collection.id] except KeyError: log.warn('No media paths dict found for rom collection %s' % rom_collection.id) return continue_update games = GameView(self.gdb).getFilteredGames(rom_collection.id, 0, 0, 0, 0, 0, 0, 0, 0, '0 = 0', '', 0) gamecount = 1 for game in games: self.progress_dialog.itemCount = len(games) #32955 = Scan artwork for Game update_message = "%s[CR]%s: %i/%i" % ( self.dialogheader, util.localize(32955), gamecount, len(games)) continue_update = self.progress_dialog.writeMsg( update_message, gamecount) if not continue_update: log.info('Update canceled') break gamecount = gamecount + 1 for media_path in rom_collection.mediaPaths: #check if we should handle this file type if str(file_type_id ) != media_path.fileType.id and file_type_id != 0: continue roms = File(self.gdb).getRomsByGameId(game[GameView.COL_ID]) gamename_from_file = rom_collection.getGamenameFromFilename( roms[0][0]) #check if artwork is available for this type file = self._find_file_in_mediadict(media_path.fileType.id, rom_collection, media_paths_dict, gamename_from_file) #check if filename has changed if game[getattr(GameView, "COL_fileType%s" % media_path.fileType.id)] != file: #write result to db # get column name from FIELDNAMES - index is the same as db column index (COL_fileTypeX) column = Game.FIELDNAMES[getattr( Game, "COL_fileType%s" % media_path.fileType.id)] Game(self.gdb).update((column, ), (file, ), game[Game.COL_ID], True) return continue_update
def test_import_gameasfolder(self): config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata', 'config', 'romcollections_importtests.xml') conf = Config(config_xml_file) conf.readXml() rcs = {} rcs[5] = conf.romCollections['5'] self.register_responses() self.register_responses_SNES() # adjust settings xbmcaddon._settings[ 'rcb_nfoFolder'] = './script.games.rom.collection.browser/nfo/' xbmcaddon._settings['rcb_PreferNfoFileIfAvailable'] = 'false' xbmcaddon._settings['rcb_ignoreGamesWithoutDesc'] = 'true' xbmcaddon._settings['rcb_scrapingMode'] = 'Automatic: Accurate' dbu = DBUpdate() dbu.updateDB(self.gdb, RCBMockGui(), rcs, False) likeStmnt = '0 = 0' games = GameView(self.gdb).getFilteredGames(5, 0, 0, 0, 0, 0, 0, 0, 0, likeStmnt, '', 0) self.assertEquals(len(games), 2) chronoTrigger = games[0] self.assertEquals(chronoTrigger[GameView.COL_NAME], 'Chrono Trigger') self.assertEquals(chronoTrigger[GameView.COL_year], '1995') self.assertTrue(chronoTrigger[GameView.COL_description].startswith( 'The 32-Meg quest begins.')) self.assertEquals(chronoTrigger[GameView.COL_genre], 'Role-Playing') self.assertEquals(chronoTrigger[GameView.COL_maxPlayers], '1') self.assertEquals(chronoTrigger[GameView.COL_publisher], 'Squaresoft') self.assertEquals(chronoTrigger[GameView.COL_developer], 'Squaresoft') roms = File(self.gdb).getRomsByGameId(chronoTrigger[GameView.COL_ID]) self.assertEquals(len(roms), 1) maddennfl = games[1] self.assertEquals(maddennfl[GameView.COL_NAME], 'Madden NFL 97') self.assertEquals(maddennfl[GameView.COL_year], '1996') self.assertTrue(maddennfl[GameView.COL_description].startswith( 'Welcome to Madden NFL 97, the game that captures the excitement of a 30 yard touchdown pass' )) self.assertEquals(maddennfl[GameView.COL_genre], 'Sports') self.assertEquals(maddennfl[GameView.COL_maxPlayers], '2') self.assertEquals(maddennfl[GameView.COL_publisher], 'Electronic Arts') self.assertEquals(maddennfl[GameView.COL_developer], 'Electronic Arts') roms = File(self.gdb).getRomsByGameId(maddennfl[GameView.COL_ID]) self.assertEquals(len(roms), 1)
def test_GetGamesByFilter(self): db_path = 'C:\\Users\\lom\\AppData\\Roaming\\Kodi\\userdata\\addon_data\\script.games.rom.collection.browser\\' gdb = GameDataBase(db_path) gdb.connect() gdb.checkDBStructure() gdb.cursor.execute("PRAGMA cache_size = 20000") import time timestamp1 = time.process_time() games = GameView(gdb).getFilteredGames(0, 0, 0, 0, 0, 0, 0, 0, 0, '0 = 0', '', 0) #games = Game(gdb).getAll() timestamp2 = time.process_time() diff = (timestamp2 - timestamp1) * 1000 print("load %d games from db in %d ms" % (len(games), diff)) timestamp1 = time.process_time() #Game(gdb).getGameById(5000) row = GameView(gdb).getGameById(5000) timestamp2 = time.process_time() diff = (timestamp2 - timestamp1) * 1000 print("load 1 game from db in %d ms" % diff)
def test_cache_artwork_1_rom_collection_1_artworktype_remove_artwork(self): # Load a config file with 2 valid RomCollections and all FileTypes and ImagePlacings config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata', 'config', 'romcollections_imageloading.xml') conf = Config(config_xml_file) conf.readXml() # image should be present at start game = GameView(self.gdb).getGameById(9) self.assertIsNotNone( game[GameView.COL_fileType4], "fileType4 expected to be present before update artwork cache") rcid = 2 artwork_type = 4 ArtworkUpdater(RCBMockGui(), self.gdb, conf).update_artwork_cache(rcid, artwork_type) # image should be removed now game = GameView(self.gdb).getGameById(9) self.assertIsNone( game[GameView.COL_fileType4], "fileType4 expected to be removed after update artwork cache") #other artwork types should be unchanged self.assertEquals( "./testdata/artwork/Atari 2600/video/Asteroids (1981) (Atari) [no copyright].png", game[GameView.COL_fileType6]) #available artwork should still be present game = GameView(self.gdb).getGameById(7) self.assertEquals( "./testdata/artwork/Atari 2600/screenshot/Adventure (1980) (Atari).jpg", game[GameView.COL_fileType4]) game = GameView(self.gdb).getGameById(8) self.assertEquals( "./testdata/artwork/Atari 2600/screenshot/Air-Sea Battle (32 in 1) (1988) (Atari) (PAL).gif", game[GameView.COL_fileType4])
def test_buildCmd_multidisc(self): rcb_launcher = RCBLauncher() config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata', 'config', 'romcollections_imageloading.xml') conf = Config(config_xml_file) conf.readXml() gameid = 6 game = GameView(self.gdb).getObjectById(gameid) filename_rows = File(self.gdb).getRomsByGameId(game[File.COL_ID]) rcb_launcher.romCollection = conf.romCollections[str( game[GameView.COL_romCollectionId])] from xbmcgui import Dialog #select disk 1 Dialog.select_result = 0 cmd, precmd, postcmd, roms = rcb_launcher._buildCmd( RCBMockGui(), filename_rows, game, False) self.assertEquals( cmd, '"/Path/To/Amiga/Emulator" "./testdata/roms/Amiga\MicroProse Formula One Grand Prix_Disk 1.adf"' ) #select disk 2 Dialog.select_result = 1 cmd, precmd, postcmd, roms = rcb_launcher._buildCmd( RCBMockGui(), filename_rows, game, False) self.assertEquals( cmd, '"/Path/To/Amiga/Emulator" "./testdata/roms/Amiga\MicroProse Formula One Grand Prix_Disk 2.adf"' ) #select disk 3 Dialog.select_result = 2 cmd, precmd, postcmd, roms = rcb_launcher._buildCmd( RCBMockGui(), filename_rows, game, False) self.assertEquals( cmd, '"/Path/To/Amiga/Emulator" "./testdata/roms/Amiga\MicroProse Formula One Grand Prix_Disk 3.adf"' ) #select disk 4 Dialog.select_result = 3 cmd, precmd, postcmd, roms = rcb_launcher._buildCmd( RCBMockGui(), filename_rows, game, False) self.assertEquals( cmd, '"/Path/To/Amiga/Emulator" "./testdata/roms/Amiga\MicroProse Formula One Grand Prix_Disk 4.adf"' )
def testFileForControl_DB(self): config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata', 'config', 'romcollections_imageloading.xml') conf = Config(config_xml_file) conf.readXml() rc_id = 1 rom_collection = conf.romCollections[str(rc_id)] game = GameView(self.gdb).getGameById(28) file = helper.get_file_for_control_from_db( rom_collection.imagePlacingMain.fileTypesForGameList, game) print(file)
def test_update_rescrape(self): """test if update a rom collection works at all: all properties should have been updated""" config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata', 'config', 'romcollections_importtests.xml') conf = Config(config_xml_file) conf.readXml() rcs = {} rcs[1] = conf.romCollections['1'] self.register_responses() self.register_responses_Amiga() # adjust settings xbmcaddon._settings[ 'rcb_nfoFolder'] = './script.games.rom.collection.browser/nfo/' xbmcaddon._settings['rcb_PreferNfoFileIfAvailable'] = 'false' xbmcaddon._settings['rcb_ignoreGamesWithoutDesc'] = 'false' xbmcaddon._settings['rcb_scrapingMode'] = 'Automatic: Accurate' xbmcaddon._settings['rcb_enableFullReimport'] = 'true' xbmcaddon._settings['rcb_overwriteWithNullvalues'] = 'false' dbu = DBUpdate() dbu.updateDB(self.gdb, RCBMockGui(), rcs, False) likeStmnt = '0 = 0' games = GameView(self.gdb).getFilteredGames(1, 0, 0, 0, 0, 0, 0, 0, 0, likeStmnt, '', 0) self.assertEquals(len(games), 4) airborneRanger = games[0] self.assertEquals(airborneRanger[GameView.COL_NAME], 'Airborne Ranger') self.assertEquals(airborneRanger[GameView.COL_year], '1990') self.assertTrue(airborneRanger[GameView.COL_description].startswith( 'Update: In this action/simulation game by Microprose the player takes the role of an U.S. Army airborne ranger.' )) self.assertEquals(airborneRanger[GameView.COL_genre], 'Action, Adventure') self.assertEquals(airborneRanger[GameView.COL_publisher], 'MicroProse Software, Inc.') self.assertEquals(airborneRanger[GameView.COL_developer], 'Imagitec Design Inc.') self.assertEquals(airborneRanger[GameView.COL_maxPlayers], '1') roms = File(self.gdb).getRomsByGameId(airborneRanger[GameView.COL_ID]) self.assertEquals(len(roms), 1)
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_cache_artwork_n_rom_collections_n_artworktypes_add_remove_artwork( self): # Load a config file with 2 valid RomCollections and all FileTypes and ImagePlacings config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata', 'config', 'romcollections_imageloading.xml') conf = Config(config_xml_file) conf.readXml() #check for correct startup values game = GameView(self.gdb).getGameById(5) self.assertIsNone( game[GameView.COL_fileType1], "fileType1 expected to be missing before update artwork cache") self.assertIsNone( game[GameView.COL_fileType4], "fileType4 expected to be missing before update artwork cache") game = GameView(self.gdb).getGameById(9) self.assertIsNotNone( game[GameView.COL_fileType4], "fileType4 expected to be present before update artwork cache") rcid = 0 artwork_type = 0 ArtworkUpdater(RCBMockGui(), self.gdb, conf).update_artwork_cache(rcid, artwork_type) # image should be available now game = GameView(self.gdb).getGameById(5) self.assertEquals("./testdata/artwork/Amiga/boxfront/Eliminator.png", game[GameView.COL_fileType1]) self.assertEquals("./testdata/artwork/Amiga/screenshot/Eliminator.png", game[GameView.COL_fileType4]) # image should be removed now game = GameView(self.gdb).getGameById(9) self.assertIsNone( game[GameView.COL_fileType4], "fileType4 expected to be removed after update artwork cache") self.assertIsNone( game[GameView.COL_fileType6], "fileType6 expected to be removed after update artwork cache") #available artwork should still be present game = GameView(self.gdb).getGameById(7) self.assertEquals( "./testdata/artwork/Atari 2600/screenshot/Adventure (1980) (Atari).jpg", game[GameView.COL_fileType4]) game = GameView(self.gdb).getGameById(8) self.assertEquals( "./testdata/artwork/Atari 2600/screenshot/Air-Sea Battle (32 in 1) (1988) (Atari) (PAL).gif", game[GameView.COL_fileType4])
def test_update_rescrape_nullvalues(self): """test if update works when rcb_overwriteWithNullvalues is set to true""" config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata', 'config', 'romcollections_importtests.xml') conf = Config(config_xml_file) conf.readXml() rcs = {} rcs[1] = conf.romCollections['1'] self.register_responses() self.register_responses_Amiga_nullvalues() # adjust settings xbmcaddon._settings[ 'rcb_nfoFolder'] = './script.games.rom.collection.browser/nfo/' xbmcaddon._settings['rcb_PreferNfoFileIfAvailable'] = 'false' xbmcaddon._settings['rcb_ignoreGamesWithoutDesc'] = 'false' xbmcaddon._settings['rcb_scrapingMode'] = 'Automatic: Accurate' xbmcaddon._settings['rcb_enableFullReimport'] = 'true' xbmcaddon._settings['rcb_overwriteWithNullvalues'] = 'true' dbu = DBUpdate() dbu.updateDB(self.gdb, RCBMockGui(), rcs, False) likeStmnt = '0 = 0' games = GameView(self.gdb).getFilteredGames(1, 0, 0, 0, 0, 0, 0, 0, 0, likeStmnt, '', 0) self.assertEquals(len(games), 4) airborneRanger = games[0] self.assertEquals(airborneRanger[GameView.COL_NAME], 'Airborne Ranger') self.assertEquals(airborneRanger[GameView.COL_year], None) self.assertEquals(airborneRanger[GameView.COL_description], '') # HACK: genres are stored in genregame link table and are not overwritten with null values self.assertEquals(airborneRanger[GameView.COL_genre], 'Action, Adventure') self.assertEquals(airborneRanger[GameView.COL_publisher], None) self.assertEquals(airborneRanger[GameView.COL_developer], None) self.assertEquals(airborneRanger[GameView.COL_maxPlayers], None) roms = File(self.gdb).getRomsByGameId(airborneRanger[GameView.COL_ID]) self.assertEquals(len(roms), 1)
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 test_buildcmd(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]) roms = [filenameRows[0][0]] fileindex = 0 emuParams = '-v -L /Applications/RetroArch.app/Contents/Resources/cores/bnes_libretro.lib "%rom%"' part_to_repeat_in_emuparams = '' precmd, postcmd, cmd = Cmd_Launcher().build_cmd( romCollection, gameRow, roms, emuParams, part_to_repeat_in_emuparams) self.assertEqual("", precmd) self.assertEqual("", postcmd) self.assertEqual( '"/Path/To/SNES/Emulator" -v -L /Applications/RetroArch.app/Contents/Resources/cores/bnes_libretro.lib "./testdata/roms/SNES\Chrono Trigger\game.sfc"', cmd)
def test_buildCmd_foldername_as_gamename(self): rcb_launcher = RCBLauncher() config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata', 'config', 'romcollections_imageloading.xml') conf = Config(config_xml_file) conf.readXml() gameid = 1 game = GameView(self.gdb).getObjectById(gameid) filename_rows = File(self.gdb).getRomsByGameId(game[File.COL_ID]) rcb_launcher.romCollection = conf.romCollections[str( game[GameView.COL_romCollectionId])] cmd, precmd, postcmd, roms = rcb_launcher._buildCmd( RCBMockGui(), filename_rows, game, False) self.assertEquals( cmd, '"/Path/To/SNES/Emulator" -v -L /Applications/RetroArch.app/Contents/Resources/cores/bnes_libretro.dylib "./testdata/roms/SNES\Chrono Trigger\game.sfc"' )
def test_buildcmd_amiga_multidisk(self): rcb_launcher = RCBLauncher() config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata', 'config', 'romcollections_launchertests.xml') conf = Config(config_xml_file) conf.readXml() gameid = 6 game = GameView(self.gdb).getObjectById(gameid) filename_rows = File(self.gdb).getRomsByGameId(game[File.COL_ID]) rcb_launcher.romCollection = conf.romCollections[str( game[GameView.COL_romCollectionId])] cmd, precmd, postcmd, roms = rcb_launcher._buildCmd( RCBMockGui(), filename_rows, game, False) self.assertEquals( cmd, '"/Path/To/Amiga/Emulator" -0 "./testdata/roms/Amiga\MicroProse Formula One Grand Prix_Disk 1.adf" -1 "./testdata/roms/Amiga\MicroProse Formula One Grand Prix_Disk 2.adf" -2 "./testdata/roms/Amiga\MicroProse Formula One Grand Prix_Disk 3.adf" -3 "./testdata/roms/Amiga\MicroProse Formula One Grand Prix_Disk 4.adf"' )
def test_buildCmd_multidisc_Amiga(self): conf = self._get_config() gameid = 6 gameRow = GameView(self.gdb).getObjectById(gameid) filename_rows = File(self.gdb).getRomsByGameId(gameRow[File.COL_ID]) roms = [f[0] for f in filename_rows] romCollection = conf.romCollections[str( gameRow[GameView.COL_romCollectionId])] emuParams = '-%I% "%ROM%"' part_to_repeat_in_emuparams = '-%I% "%ROM%"' launcher = Cmd_Launcher() precmd, postcmd, cmd = launcher.build_cmd(romCollection, gameRow, roms, emuParams, part_to_repeat_in_emuparams) print(cmd) self.assertEqual( cmd, '"/Path/To/Amiga/Emulator" -0 "./testdata/roms/Amiga\MicroProse Formula One Grand Prix_Disk 1.adf" -1 "./testdata/roms/Amiga\MicroProse Formula One Grand Prix_Disk 2.adf" -2 "./testdata/roms/Amiga\MicroProse Formula One Grand Prix_Disk 3.adf" -3 "./testdata/roms/Amiga\MicroProse Formula One Grand Prix_Disk 4.adf"' ) """