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_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 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)
Esempio n. 4
0
    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_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_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)
Esempio n. 7
0
    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_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 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_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)
Esempio n. 13
0
    def test_update_norescrape_config_allowupdate(self):
        """test if update is skipped when allowupdate is set to false in config.xml"""
        config_xml_file = os.path.join(os.path.dirname(__file__), 'testdata',
                                       'config',
                                       'romcollections_allowupdate.xml')
        conf = Config(config_xml_file)
        conf.readXml()

        rcs = {}
        rcs[1] = conf.romCollections['1']

        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_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 = Game(self.gdb).getGamesByFilter(1, 0, 0, 0, 0, likeStmnt)

        self.assertEquals(len(games), 4)
        airborneRanger = games[0]
        self.assertEquals(airborneRanger.name, 'Airborne Ranger')
        self.assertEquals(airborneRanger.year, '1989')
        self.assertTrue(
            airborneRanger.plot.startswith(
                'In this action/simulation game by Microprose the player takes the role of an U.S. Army airborne ranger.'
            ))
        self.assertEquals(airborneRanger.genre, 'Action, Adventure')
        self.assertEquals(airborneRanger.publisher, 'MicroProse')
        self.assertEquals(airborneRanger.developer, 'Imagitec')
        self.assertEquals(airborneRanger.maxPlayers, '1')
        roms = File(self.gdb).getRomsByGameId(airborneRanger.id)
        self.assertEquals(len(roms), 1)
    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"'
        )
Esempio n. 15
0
    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"'
        )
        """
Esempio n. 16
0
    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_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"'
        )
Esempio n. 18
0
    def test_import_initial_special_characters(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[3] = conf.romCollections['3']

        self.register_responses()
        self.register_responses_N64()

        # 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(3, 0, 0, 0, 0, 0, 0, 0, 0,
                                                    likeStmnt, '', 0)

        self.assertEquals(len(games), 1)
        snowboarding = games[0]
        self.assertEquals(snowboarding[GameView.COL_NAME],
                          u'1080\xb0 Snowboarding')
        # TODO check for description with special characters
        # self.assertTrue(snowboarding[GameView.COL_description].startswith(u"You’re taking a Tahoe 155 snowboard down a steep, bumpy incline at night and you’re about to top off an Indy Nosebone with a 360° Air"))
        self.assertEquals(snowboarding[GameView.COL_year], '1998')
        self.assertEquals(snowboarding[GameView.COL_genre], 'Sports')
        self.assertEquals(snowboarding[GameView.COL_publisher], 'Nintendo')
        self.assertEquals(snowboarding[GameView.COL_developer], 'Nintendo EAD')
        roms = File(self.gdb).getRomsByGameId(snowboarding[GameView.COL_ID])
        self.assertEquals(len(roms), 1)
Esempio n. 19
0
	def gatherWidgetData(self, param):
		print 'start gatherWidgetData'
		import util, helper
		from gamedatabase import Game, GameDataBase, File
		from config import Config, RomCollection
		
		gdb = GameDataBase(util.getAddonDataPath())
		gdb.connect()
		
		doImport, errorMsg = gdb.checkDBStructure()
		if(doImport) > 0:
			print "RCB: No database available. Won't gather any data."
			gdb.close()
			return
				
		#cache lookup tables
		yearDict = helper.cacheYears(gdb)
		publisherDict = helper.cachePublishers(gdb)
		developerDict = helper.cacheDevelopers(gdb)
		reviewerDict = helper.cacheReviewers(gdb)
		genreDict = helper.cacheGenres(gdb)
				
		limit = int(param.replace('limit=', ''))
		games = Game(gdb).getMostPlayedGames(limit)
		print 'most played games: %s' %games
		
		config = Config(None)
		statusOk, errorMsg = config.readXml()
		
		settings = util.getSettings()
		
		import xbmcgui
		count = 0
		for gameRow in games:
		
			count += 1
			try:
				print "Gathering data for rom no %i: %s" %(count, gameRow[util.ROW_NAME])
				
				romCollection = config.romCollections[str(gameRow[util.GAME_romCollectionId])]				
		
				#get artwork that is chosen to be shown in gamelist
				files = File(gdb).getFilesByParentIds(gameRow[util.ROW_ID], gameRow[util.GAME_romCollectionId], gameRow[util.GAME_publisherId], gameRow[util.GAME_developerId])
				fileDict = helper.cacheFiles(files)
				files = helper.getFilesByControl_Cached(gdb, romCollection.imagePlacingMain.fileTypesForGameList, gameRow[util.ROW_ID], gameRow[util.GAME_publisherId], gameRow[util.GAME_developerId], gameRow[util.GAME_romCollectionId], fileDict)		
				if(files != None and len(files) != 0):
					thumb = files[0]
				else:
					thumb = ""
					
				files = helper.getFilesByControl_Cached(gdb, romCollection.imagePlacingMain.fileTypesForMainViewBackground, gameRow[util.ROW_ID], gameRow[util.GAME_publisherId], gameRow[util.GAME_developerId], gameRow[util.GAME_romCollectionId], fileDict)		
				if(files != None and len(files) != 0):
					fanart = files[0]
				else:
					fanart = ""
				
				description = gameRow[util.GAME_description]
				if(description == None):
					description = ""
				
				year = helper.getPropertyFromCache(gameRow, yearDict, util.GAME_yearId, util.ROW_NAME)
				publisher = helper.getPropertyFromCache(gameRow, publisherDict, util.GAME_publisherId, util.ROW_NAME)
				developer = helper.getPropertyFromCache(gameRow, developerDict, util.GAME_developerId, util.ROW_NAME)
				genre = genreDict[gameRow[util.ROW_ID]]
				
				maxplayers = helper.saveReadString(gameRow[util.GAME_maxPlayers])
				rating = helper.saveReadString(gameRow[util.GAME_rating])
				votes = helper.saveReadString(gameRow[util.GAME_numVotes])
				url = helper.saveReadString(gameRow[util.GAME_url])
				region = helper.saveReadString(gameRow[util.GAME_region])
				media = helper.saveReadString(gameRow[util.GAME_media])				
				perspective = helper.saveReadString(gameRow[util.GAME_perspective])
				controllertype = helper.saveReadString(gameRow[util.GAME_controllerType])
				originaltitle = helper.saveReadString(gameRow[util.GAME_originalTitle])
				alternatetitle = helper.saveReadString(gameRow[util.GAME_alternateTitle])
				translatedby = helper.saveReadString(gameRow[util.GAME_translatedBy])
				version = helper.saveReadString(gameRow[util.GAME_version])
				playcount = helper.saveReadString(gameRow[util.GAME_launchCount])
				
				#get launch command
				filenameRows = File(gdb).getRomsByGameId(gameRow[util.ROW_ID])
				
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Id" %count, str(gameRow[util.ROW_ID]))
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Console" %count, romCollection.name)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Title" %count, gameRow[util.ROW_NAME])
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Thumb" %count, thumb)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Fanart" %count, fanart)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Plot" %count, description)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Year" %count, year)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Publisher" %count, publisher)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Developer" %count, developer)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Genre" %count, genre)
				
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Maxplayers" %count, maxplayers)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Region" %count, region)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Media" %count, media)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Perspective" %count, perspective)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Controllertype" %count, controllertype)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Playcount" %count, playcount)				
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Rating" %count, rating)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Votes" %count, votes)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Url" %count, url)				
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Originaltitle" %count, originaltitle)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Alternatetitle" %count, alternatetitle)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Translatedby" %count, translatedby)
				xbmcgui.Window(10000).setProperty("MostPlayedROM.%d.Version" %count, version)
								
			except Exception, (exc):
				print 'RCB: Error while getting most played games: ' +str(exc)
    def test_import_initial_accurate_gameswithoutdesc(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[1] = conf.romCollections['1']

        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'

        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], '1989')
        self.assertTrue(airborneRanger[GameView.COL_description].startswith(
            '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')
        self.assertEquals(airborneRanger[GameView.COL_developer], 'Imagitec')
        self.assertEquals(airborneRanger[GameView.COL_maxPlayers], '1')
        roms = File(self.gdb).getRomsByGameId(airborneRanger[GameView.COL_ID])
        self.assertEquals(len(roms), 1)

        chuckRock = games[1]
        self.assertEquals(chuckRock[GameView.COL_NAME], 'Chuck Rock')
        self.assertEquals(chuckRock[GameView.COL_year], '1991')
        self.assertTrue(chuckRock[GameView.COL_description].startswith(
            "Chuck Rock hasn't been the same since his long-time rival in love, the evil Gary Gritter, kidnapped his wife, the beautiful Ophelia."
        ))
        self.assertEquals(chuckRock[GameView.COL_genre], 'Platform')
        self.assertEquals(chuckRock[GameView.COL_publisher], 'Core Design')
        self.assertEquals(chuckRock[GameView.COL_developer], 'Core Design')
        self.assertEquals(chuckRock[GameView.COL_maxPlayers], '1')
        self.assertEquals(chuckRock[GameView.COL_rating], '8')
        roms = File(self.gdb).getRomsByGameId(chuckRock[GameView.COL_ID])
        self.assertEquals(len(roms), 1)

        eliminator = games[2]
        self.assertEquals(eliminator[GameView.COL_NAME], 'Eliminator')
        self.assertEquals(eliminator[GameView.COL_year], None)
        roms = File(self.gdb).getRomsByGameId(eliminator[GameView.COL_ID])
        self.assertEquals(len(roms), 1)

        formulaOne = games[3]
        self.assertEquals(formulaOne[GameView.COL_NAME],
                          'MicroProse Formula One Grand Prix')
        self.assertEquals(formulaOne[GameView.COL_year], '1991')
        self.assertTrue(formulaOne[GameView.COL_description].startswith(
            "MicroProse Formula One Grand Prix is a racing simulator released in 1991 by MicroProse and created by game designer Geoff Crammond."
        ))
        #HACK: Order of genres depends on id in database. If we run the full set of tests Genre Sports might already be
        #in database and has a lower id than Racing
        self.assertTrue(formulaOne[GameView.COL_genre] == 'Racing, Sports'
                        or formulaOne[GameView.COL_genre] == 'Sports, Racing')
        self.assertEquals(formulaOne[GameView.COL_publisher], 'MicroProse')
        self.assertEquals(formulaOne[GameView.COL_developer], None)
        self.assertEquals(formulaOne[GameView.COL_maxPlayers], '1')
        roms = File(self.gdb).getRomsByGameId(formulaOne[GameView.COL_ID])
        self.assertEquals(len(roms), 4)