def test_loading_the_roms_filtered_of_launcher_works_correctly(self, mock_exeFactory, is_linux_mock,is_android_mock, is_win_mock): # arrange is_linux_mock.return_value = False is_win_mock.return_value = False is_android_mock.return_value = True settings = self._get_test_settings() launcher_data = {} launcher_data['type'] = OBJ_LAUNCHER_RETROARCH launcher_data['id'] = 'ABC' launcher_data['toggle_window'] = True launcher_data['romext'] = None launcher_data['args_extra'] = None launcher_data['roms_base_noext'] = 'roms_Sega_32X_518519' launcher_data['application'] = 'app' mock = FakeExecutor() mock_exeFactory.create.return_value = mock paths = Fake_Paths('\\fake\\') paths.ROMS_DIR = PythonFileName(self.TEST_ASSETS_DIR) repository = ROMSetRepository(paths, settings) target = StandardRomLauncher(paths, settings, launcher_data, None, mock_exeFactory, repository, None) expected = 35 # act actual = target.get_roms_filtered() # assert self.assertIsNotNone(actual) self.assertEqual(len(actual), expected)
def test_when_reading_rom_files_it_will_get_the_correct_collection( self, mock_file): # arrange settings = self._get_test_settings() rom_dir = PythonFileName(self.TEST_ASSETS_DIR) paths = Fake_Paths('\\fake\\') paths.ROMS_DIR = rom_dir target = ROMSetRepository(paths, settings) launcher_data = { 'id': 'abc', 'roms_base_noext': 'roms_Sega_32X_518519' } launcher = StandardRomLauncher(paths, settings, launcher_data, None, None, target, None) expected = 35 # act actual = target.load_ROMs(launcher) # assert self.assertIsNotNone(actual) self.assertEqual(len(actual), expected)
def test_if_retroarch_launcher_will_apply_the_correct_arguments_when_running_on_android( self, mock_exeFactory, is_linux_mock, is_android_mock, is_win_mock, mock_file): # arrange is_linux_mock.return_value = False is_win_mock.return_value = False is_android_mock.return_value = True settings = self._get_test_settings() launcher_data = {} launcher_data['type'] = OBJ_LAUNCHER_RETROARCH launcher_data['id'] = 'ABC' launcher_data['toggle_window'] = True launcher_data['romext'] = None launcher_data['args_extra'] = None launcher_data['roms_base_noext'] = 'snes' launcher_data[ 'retro_core'] = '/data/data/com.retroarch/cores/mame_libretro_android.so' launcher_data[ 'retro_config'] = '/storage/emulated/0/Android/data/com.retroarch/files/retroarch.cfg' launcher_data['application'] = None rom_id = 'qqqq' rom = {} rom['id'] = 'qqqq' rom['m_name'] = 'TestCase' rom['filename'] = 'superrom.zip' rom['altapp'] = None roms = {rom_id: rom} json_data = json.dumps(roms, ensure_ascii=False, indent=1, separators=(',', ':')) rom_dir = FakeFile(self.TEST_ASSETS_DIR) rom_dir.setFakeContent(json_data) mock = FakeExecutor() mock_exeFactory.create.return_value = mock paths = Fake_Paths('\\fake\\') paths.ROMS_DIR = rom_dir repository = ROMSetRepository(paths, settings) launcher = RetroarchLauncher(paths, settings, launcher_data, None, mock_exeFactory, repository, None) launcher.select_ROM(rom_id) expected = '/system/bin/am' expectedArgs = "start --user 0 -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n com.retroarch/.browser.retroactivity.RetroActivityFuture -e ROM 'superrom.zip' -e LIBRETRO /data/data/com.retroarch/cores/mame_libretro_android.so -e CONFIGFILE /storage/emulated/0/Android/data/com.retroarch/files/retroarch.cfg " # act launcher.launch() # assert self.assertEqual(expected, mock.getActualApplication().getPath()) self.assertEqual(expectedArgs, mock.actualArgs)
def test_if_rom_launcher_will_apply_the_correct_disc_in_a_multidisc_situation( self, mock_exeFactory, mock_dialog, mock_file): # arrange settings = self._get_test_settings() launcher_data = {} launcher_data['id'] = 'ABC' launcher_data['type'] = OBJ_LAUNCHER_ROM launcher_data['application'] = 'c:\\temp\\' launcher_data['toggle_window'] = True launcher_data['romext'] = '' launcher_data['application'] = '' launcher_data['args'] = '-a -b -c -d -e $rom$ -yes' launcher_data['args_extra'] = '' launcher_data['roms_base_noext'] = 'snes' rom = {} rom['id'] = 'qqqq' rom['m_name'] = 'TestCase' rom['filename'] = 'd:\\games\\discXX.zip' rom['altapp'] = '' rom['altarg'] = '' rom['disks'] = ['disc01.zip', 'disc02.zip'] rom_id = rom['id'] roms = {rom_id: rom} json_data = json.dumps(roms, ensure_ascii=False, indent=1, separators=(',', ':')) rom_dir = FakeFile(self.TEST_ASSETS_DIR) rom_dir.setFakeContent(json_data) mock_dialog.return_value = 1 mock = FakeExecutor() mock_exeFactory.create.return_value = mock paths = Fake_Paths('\\fake\\') paths.ROMS_DIR = rom_dir repository = ROMSetRepository(paths, settings) launcher = StandardRomLauncher(paths, settings, launcher_data, None, mock_exeFactory, repository, None) launcher.select_ROM(rom_id) expected = launcher_data['application'] expectedArgs = '-a -b -c -d -e d:\\games\\disc02.zip -yes' # act launcher.launch() # assert self.assertEqual(expectedArgs, mock.actualArgs)
def test_if_rom_launcher_will_correctly_passthrough_the_application_when_launching( self, mock_exeFactory, mock_file): # arrange settings = self._get_test_settings() launcher_data = {} launcher_data['id'] = 'ABC' launcher_data['type'] = OBJ_LAUNCHER_ROM launcher_data['application'] = 'path' launcher_data['toggle_window'] = True launcher_data['romext'] = '' launcher_data['application'] = '' launcher_data['args'] = '-a -b -c -d -e $rom$ -yes' launcher_data['args_extra'] = '' launcher_data['roms_base_noext'] = 'snes' rom_id = 'fghj' rom = { 'id': rom_id, 'm_name': 'TestCase', 'filename': 'testing.zip', 'altapp': '', 'altarg': '' } roms = {rom_id: rom} json_data = json.dumps(roms, ensure_ascii=False, indent=1, separators=(',', ':')) rom_dir = FakeFile(self.TEST_ASSETS_DIR) rom_dir.setFakeContent(json_data) mock = FakeExecutor() mock_exeFactory.create.return_value = mock paths = Fake_Paths('\\fake\\') paths.ROMS_DIR = rom_dir repository = ROMSetRepository(paths, settings) launcher = StandardRomLauncher(paths, settings, launcher_data, None, mock_exeFactory, repository, None) launcher.select_ROM(rom_id) expected = launcher_data['application'] expectedArgs = '-a -b -c -d -e testing.zip -yes' # act launcher.launch() # assert self.assertIsNotNone(mock.actualApplication) self.assertEqual(expected, mock.actualApplication.getPath()) self.assertEqual(expectedArgs, mock.actualArgs)
def test_if_rom_launcher_will_use_the_multidisk_launcher_when_romdata_has_disks_field_filled_in( self, mock_exeFactory, mock_file): # arrange settings = self._get_test_settings() launcher_data = {} launcher_data['id'] = 'ABC' launcher_data['type'] = OBJ_LAUNCHER_ROM launcher_data['application'] = 'path' launcher_data['toggle_window'] = True launcher_data['romext'] = '' launcher_data['application'] = '' launcher_data['args'] = '' launcher_data['args_extra'] = '' launcher_data['roms_base_noext'] = 'snes' rom_id = 'fghj' rom = { 'id': rom_id, 'm_name': 'TestCase', 'disks': ['disc01.zip', 'disc02.zip'] } roms = {rom_id: rom} json_data = json.dumps(roms, ensure_ascii=False, indent=1, separators=(',', ':')) rom_dir = FakeFile(self.TEST_ASSETS_DIR) rom_dir.setFakeContent(json_data) mock = FakeExecutor() mock_exeFactory.create.return_value = mock paths = Fake_Paths('\\fake\\') paths.ROMS_DIR = rom_dir repository = ROMSetRepository(paths, settings) launcher = StandardRomLauncher(paths, settings, launcher_data, None, mock_exeFactory, repository, None) # act launcher.select_ROM(rom_id) # assert actual = launcher.__class__.__name__ expected = 'StandardRomLauncher' self.assertEqual(actual, expected)
def test_when_using_rom_the_factory_will_get_the_correct_launcher( self, mock_exeFactory): # arrange settings = self._get_test_settings() launcher_data = {} launcher_data['id'] = 'ABC' launcher_data['application'] = 'path' launcher_data['type'] = OBJ_LAUNCHER_ROM launcher_data['toggle_window'] = True launcher_data['romext'] = '' launcher_data['application'] = '' launcher_data['args'] = '' launcher_data['args_extra'] = '' launcher_data['roms_base_noext'] = 'snes' rom_id = 'fghj' rom = {'id': rom_id, 'm_name': 'TestCase'} roms = {rom_id: rom} json_data = json.dumps(roms, ensure_ascii=False, indent=1, separators=(',', ':')) rom_dir = FakeFile(self.TEST_ASSETS_DIR) rom_dir.setFakeContent(json_data) paths = Fake_Paths('\\fake\\') paths.ROMS_DIR = NewFileName(self.TEST_ASSETS_DIR) repository = ROMSetRepository(paths, settings) # act launcher = StandardRomLauncher(paths, settings, launcher_data, None, mock_exeFactory, repository, None) launcher.select_ROM(rom_id) # assert actual = launcher.__class__.__name__ expected = 'StandardRomLauncher' self.assertEqual(actual, expected)
def test_storing_roms_will_create_a_file_with_correct_contents(self): # arrange settings = self._get_test_settings() rom_dir = FakeFile(self.TEST_ASSETS_DIR) paths = Fake_Paths('\\fake\\') paths.ROMS_DIR = rom_dir target = ROMSetRepository(paths, settings) launcher_data = {'id': 'abc', 'roms_base_noext': 'testcase'} launcher = StandardRomLauncher(paths, settings, launcher_data, None, None, target, None) roms = {} roms['1234'] = ROM() roms['9998'] = ROM() roms['7845'] = ROM() # act target.save_rom_set(launcher, roms) # assert print(rom_dir.getFakeContent())