@Test
  public void testRounding() throws Exception {
    PrettyTime t = new PrettyTime(new Date(1000 * 60 * 60 * 3 + 1000 * 60 * 45));
    Duration duration = t.approximateDuration(new Date(0));
    TimeFormat format = duration.getUnit().getFormat();

    assertEquals("4 hours", format.format(duration));
    assertEquals("3 hours", format.formatUnrounded(duration));
  }
  @Test
  public void testDecorating() throws Exception {
    PrettyTime t = new PrettyTime();
    TimeFormat format = new BasicTimeFormat().setFutureSuffix("from now").setPastSuffix("ago");

    Duration duration = t.approximateDuration(new Date(System.currentTimeMillis() + 1000));
    assertEquals("some time from now", format.decorate(duration, "some time"));

    duration = t.approximateDuration(new Date(System.currentTimeMillis() - 10000));
    assertEquals("some time ago", format.decorate(duration, "some time"));
  }
  private Table makeGameFileInfoBox(
      final Table fileRow, final FileHandle savedGameFile, GameSave towerData) {
    TextButton launchButton = FontManager.RobotoBold18.makeTextButton("Play");
    launchButton.addListener(
        new VibrateClickListener() {
          @Override
          public void onClick(InputEvent event, float x, float y) {
            dismiss();
            try {
              SceneManager.changeScene(
                  LoadTowerSplashScene.class, GameSaveFactory.readFile(savedGameFile));
            } catch (Exception e) {
              throw new RuntimeException(e);
            }
          }
        });

    TextButton deleteButton = FontManager.RobotoBold18.makeTextButton("Delete");
    deleteButton.addListener(
        new VibrateClickListener() {
          @Override
          public void onClick(InputEvent event, float x, float y) {
            new Dialog()
                .setTitle("Are you sure you want to delete this Tower?")
                .setMessage("If you delete this tower, it will disappear forever.\n\nAre you sure?")
                .addButton(
                    "Yes, delete it",
                    new OnClickCallback() {
                      @Override
                      public void onClick(Dialog dialog) {
                        savedGameFile.delete();

                        content.getCell(fileRow).ignore();
                        content.removeActor(fileRow);
                        content.invalidate();

                        dialog.dismiss();
                      }
                    })
                .addButton(
                    "Keep it!",
                    new OnClickCallback() {
                      @Override
                      public void onClick(Dialog dialog) {
                        dialog.dismiss();
                      }
                    })
                .show();
          }
        });

    Table metadata = new Table();
    metadata.defaults().top().left().fillX();
    addLabelRow(metadata, towerData.getTowerName(), FontManager.RobotoBold18, Color.WHITE);
    addLabelRow(
        metadata,
        "Population: " + getNumberInstance().format(towerData.getPlayer().getTotalPopulation()),
        FontManager.Default,
        Color.GRAY);
    Date lastPlayed = towerData.getMetadata().lastPlayed;
    if (lastPlayed != null) {
      PrettyTime prettyTime = new PrettyTime();
      addLabelRow(
          metadata,
          "Last played: " + prettyTime.format(lastPlayed),
          FontManager.Default,
          Color.GRAY);
    }

    Table box = new Table();
    box.defaults().fillX().space(Display.devicePixel(5));
    box.row().top().left().fillX();
    box.add(metadata).top().left().expandX();
    box.add(deleteButton).width(Display.devicePixel(80));
    box.add(launchButton).width(Display.devicePixel(80));

    return box;
  }