Unit tests for the removable drive plugin.

This commit is contained in:
akwizgran
2011-10-04 22:04:10 +01:00
parent f4af582592
commit 18723a56ae
6 changed files with 256 additions and 33 deletions

View File

@@ -91,7 +91,6 @@ abstract class FilePlugin implements BatchTransportPlugin {
OutputStream out = new FileOutputStream(f);
return new FileTransportWriter(f, out, capacity, this);
} catch(IOException e) {
e.printStackTrace();
f.delete();
return null;
}

View File

@@ -4,14 +4,24 @@ import java.io.File;
import java.io.IOException;
import java.util.List;
import net.sf.briar.api.TransportId;
class RemovableDrivePlugin extends FilePlugin {
public static final int TRANSPORT_ID = 0;
private static final TransportId id = new TransportId(TRANSPORT_ID);
private final RemovableDriveFinder finder;
RemovableDrivePlugin(RemovableDriveFinder finder) {
this.finder = finder;
}
public TransportId getId() {
return id;
}
@Override
protected File chooseOutputDirectory() {
try {
@@ -19,7 +29,7 @@ class RemovableDrivePlugin extends FilePlugin {
if(drives.isEmpty()) return null;
String[] paths = new String[drives.size()];
for(int i = 0; i < paths.length; i++) {
paths[i] = drives.get(i).getAbsolutePath();
paths[i] = drives.get(i).getPath();
}
int i = callback.showChoice("REMOVABLE_DRIVE_CHOOSE_DRIVE", paths);
if(i == -1) return null;

View File

@@ -9,9 +9,7 @@ import java.util.Scanner;
abstract class UnixRemovableDriveFinder implements RemovableDriveFinder {
protected abstract String getMountCommand();
protected abstract String parseMountPoint(String line);
protected abstract boolean isRemovableDriveMountPoint(String path);
public List<File> findRemovableDrives() throws IOException {