Ejemplo n.º 1
0
  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());
  }
Ejemplo n.º 2
0
 public void onDestroyActionModeUnpacking(ActionMode mode) {
   Iterator<Integer> iterator = checkedSounds.iterator();
   while (iterator.hasNext()) {
     int position = iterator.next();
     SoundController.getInstance()
         .copySound(
             soundInfoItems.get(position),
             BackPackListManager.getCurrentSoundInfoArrayList(),
             BackPackListManager.getCurrentAdapter());
   }
   backPackSoundFragment.clearCheckedSoundsAndEnableButtons();
 }
Ejemplo n.º 3
0
  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());
  }
Ejemplo n.º 4
0
  @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;
    }
  }
Ejemplo n.º 5
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       if (returnToProjectsList) {
         Intent intent = new Intent(this, MyProjectsActivity.class);
         intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
         BackPackListManager.setBackPackFlag(true);
         startActivity(intent);
       } else {
         Intent intent = new Intent(this, MainMenuActivity.class);
         intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
         BackPackListManager.setBackPackFlag(true);
         startActivity(intent);
       }
       break;
     case R.id.settings:
       Intent settingsIntent = new Intent(this, SettingsActivity.class);
       startActivity(settingsIntent);
       break;
     case R.id.menu_rate_app:
       launchMarket();
       return true;
     case R.id.menu_terms_of_use:
       TermsOfUseDialogFragment termsOfUseDialog = new TermsOfUseDialogFragment();
       termsOfUseDialog.show(
           getSupportFragmentManager(), TermsOfUseDialogFragment.DIALOG_FRAGMENT_TAG);
       return true;
     case R.id.menu_about:
       AboutDialogFragment aboutDialog = new AboutDialogFragment();
       aboutDialog.show(getSupportFragmentManager(), AboutDialogFragment.DIALOG_FRAGMENT_TAG);
       return true;
     default:
       break;
   }
   return super.onOptionsItemSelected(item);
 }
Ejemplo n.º 6
0
  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;
  }