public void testDeserializeInvalidBackpackFile() throws IOException { File backPackFile = loadBackpackFile(backpackJsonInvalid); BackPackListManager.getInstance().loadBackpack(); TestUtils.sleep(1000); assertTrue( "Backpacked items loaded despite file is invalid!", BackPackListManager.getInstance().getBackpack().backpackedScripts.isEmpty()); assertFalse("Backpack.json should be deleted!", backPackFile.exists()); }
public void testDeserializeValidBackpackFile() throws IOException { File backPackFile = loadBackpackFile(backpackJsonValid); BackPackListManager.getInstance().loadBackpack(); TestUtils.sleep(1000); assertFalse( "Backpacked sprites not loaded!", BackPackListManager.getInstance().getBackpack().backpackedSprites.isEmpty()); assertFalse( "Backpacked scripts not loaded!", BackPackListManager.getInstance().getBackpack().hiddenBackpackedScripts.isEmpty()); assertFalse( "Backpacked looks not loaded!", BackPackListManager.getInstance().getBackpack().hiddenBackpackedLooks.isEmpty()); assertFalse( "Backpacked sounds not loaded!", BackPackListManager.getInstance().getBackpack().hiddenBackpackedSounds.isEmpty()); assertTrue("Backpack.json should not be deleted!", backPackFile.exists()); }
private File loadBackpackFile(String jsonName) throws IOException { UiTestUtils.clearBackPack(true); InputStream inputStream = getInstrumentation().getContext().getResources().getAssets().open(jsonName); File backPackFile = new File(backpackFilePath); assertFalse("Backpack.json should not exist!", backPackFile.exists()); byte[] buffer = new byte[inputStream.available()]; inputStream.read(buffer); File targetFile = new File(backpackFilePath); OutputStream outStream = new FileOutputStream(targetFile); outStream.write(buffer); assertTrue("Backpack.json should exist!", backPackFile.exists()); assertTrue( "Backpacked items not deleted!", BackPackListManager.getInstance().getBackpack().backpackedScripts.isEmpty()); return backPackFile; }
@Override protected void onResume() { super.onResume(); if (backpackItem) { Iterator<SoundInfo> iterator = BackPackListManager.getActionBarSoundInfoArrayList().iterator(); while (iterator.hasNext()) { SoundInfo soundInfo = iterator.next(); BackPackListManager.setCurrentSoundInfo(soundInfo); SoundController.getInstance() .backPackSound( BackPackListManager.getCurrentSoundInfo(), backPackSoundFragment, BackPackListManager.getInstance().getSoundInfoArrayList(), backPackSoundFragment.getAdapter()); } BackPackListManager.getActionBarSoundInfoArrayList().clear(); backpackItem = false; } }