ScreenRecorderAction extends AbstractDeviceAction { @VisibleForTesting static String getEmulatorScreenRecorderOptions(@NotNull Path filePath, @NotNull ScreenRecorderOptions options) { StringBuilder sb = new StringBuilder(); if (options.width > 0 && options.height > 0) { sb.append("--size "); sb.append(options.width); sb.append('x'); sb.append(options.height); sb.append(' '); } if (options.bitrateMbps > 0) { sb.append("--bit-rate "); sb.append(options.bitrateMbps * 1000000); sb.append(' '); } if (options.timeLimit > 0) { sb.append("--time-limit "); long seconds = TimeUnit.SECONDS.convert(options.timeLimit, options.timeLimitUnits); if (seconds > 180) { seconds = 180; } sb.append(seconds); sb.append(' '); } sb.append(filePath); return sb.toString(); } ScreenRecorderAction(@NotNull Project project, @NotNull DeviceContext context); @VisibleForTesting  ScreenRecorderAction(@NotNull Project project, @NotNull DeviceContext context, @NotNull Features features); @Override void update(@NotNull AnActionEvent event);  }
@Test public void getEmulatorScreenRecorderOptions() { Path path = Jimfs.newFileSystem().getPath("sdcard", "1.mp4"); String expectedPath = path.toString(); assert expectedPath.equals("sdcard" + File.separator + "1.mp4"); ScreenRecorderOptions options = new ScreenRecorderOptions.Builder() .setBitRate(6) .setSize(600, 400) .build(); assertEquals("--size 600x400 --bit-rate 6000000 " + expectedPath, ScreenRecorderAction.getEmulatorScreenRecorderOptions(path, options)); options = new ScreenRecorderOptions.Builder() .setTimeLimit(100, TimeUnit.SECONDS) .build(); assertEquals("--time-limit 100 " + expectedPath, ScreenRecorderAction.getEmulatorScreenRecorderOptions(path, options)); options = new ScreenRecorderOptions.Builder() .setTimeLimit(4, TimeUnit.MINUTES) .build(); assertEquals("--time-limit 180 " + expectedPath, ScreenRecorderAction.getEmulatorScreenRecorderOptions(path, options)); }