AdbFileOperations { @NotNull public ListenableFuture<Void> createNewDirectory(@NotNull String parentPath, @NotNull String directoryName) { return createNewDirectoryRunAs(parentPath, directoryName, null); } AdbFileOperations(@NotNull IDevice device, @NotNull AdbDeviceCapabilities deviceCapabilities, @NotNull Executor taskExecutor); @NotNull ListenableFuture<Void> createNewFile(@NotNull String parentPath, @NotNull String fileName); @NotNull ListenableFuture<Void> createNewFileRunAs(@NotNull String parentPath, @NotNull String fileName, @Nullable String runAs); @NotNull ListenableFuture<Void> createNewDirectory(@NotNull String parentPath, @NotNull String directoryName); @NotNull ListenableFuture<Void> createNewDirectoryRunAs(@NotNull String parentPath, @NotNull String directoryName, @Nullable String runAs); ListenableFuture<List<String>> listPackages(); ListenableFuture<List<PackageInfo>> listPackageInfo(); @NotNull ListenableFuture<Void> deleteFile(@NotNull String path); @NotNull ListenableFuture<Void> deleteFileRunAs(@NotNull String path, @Nullable String runAs); @NotNull ListenableFuture<Void> deleteRecursive(@NotNull String path); @NotNull ListenableFuture<Void> deleteRecursiveRunAs(@NotNull String path, @Nullable String runAs); @NotNull ListenableFuture<Void> copyFile(@NotNull String source, @NotNull String destination); @NotNull ListenableFuture<Void> copyFileRunAs(@NotNull String source, @NotNull String destination, @Nullable String runAs); @NotNull ListenableFuture<String> createTempFile(@NotNull String tempPath); @SuppressWarnings({"SameParameterValue", "WeakerAccess"}) @NotNull ListenableFuture<String> createTempFileRunAs(@NotNull String tempDirectoy, @Nullable String runAs); @NotNull ListenableFuture<Void> touchFileAsDefaultUser(@NotNull String remotePath);  }
@Test public void testCreateNewDirectorySuccess() throws Exception { AdbFileOperations fileOperations = setupMockDevice(); Void result = waitForFuture(fileOperations.createNewDirectory("/sdcard", "foo-dir")); assertThat(result).isNull(); }
@Test public void testCreateNewDirectoryInvalidNameError() throws Exception { AdbFileOperations fileOperations = setupMockDevice(); thrown.expect(ExecutionException.class); thrown.expectCause(IsInstanceOf.instanceOf(AdbShellCommandException.class)); waitForFuture(fileOperations.createNewDirectory("/", "fo/o-dir")); }
@Test public void testCreateNewDirectoryReadOnlyError() throws Exception { AdbFileOperations fileOperations = setupMockDevice(); thrown.expect(ExecutionException.class); thrown.expectCause(IsInstanceOf.instanceOf(AdbShellCommandException.class)); waitForFuture(fileOperations.createNewDirectory("/", "foo-dir")); }
@Test public void testCreateNewDirectoryPermissionError() throws Exception { AdbFileOperations fileOperations = setupMockDevice(); thrown.expect(ExecutionException.class); thrown.expectCause(IsInstanceOf.instanceOf(AdbShellCommandException.class)); waitForFuture(fileOperations.createNewDirectory("/system", "foo-dir")); }
@Test public void testCreateNewDirectoryExistError() throws Exception { AdbFileOperations fileOperations = setupMockDevice(); thrown.expect(ExecutionException.class); thrown.expectCause(IsInstanceOf.instanceOf(AdbShellCommandException.class)); waitForFuture(fileOperations.createNewDirectory("/", "data")); }